Casting SPELs in Lisp (newLISP)

Q&A's, tips, howto's
Locked
_ex_
Posts: 23
Joined: Wed Aug 23, 2006 3:17 pm
Location: Peru

Casting SPELs in Lisp (newLISP)

Post by _ex_ »

Well I found this excellent newbie tutorial

http://www.lisperati.com/actions.html

But I'm having troubles trying to translate this code to newLISP

Code: Select all

(defun describe-path (path)
  `(there is a ,(second path) going ,(first path) from here.))
I read the documentation and couldn't find something like (`) and also commas are used differently, there is a way to get this in newLISP?

Regards.

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

No, this is Common LISP an older standard of LISP very different from newLISP. If you are looking for newLISP introductions read this:

http://newlisp.org/introduction-to-newlisp.pdf
or
http://newlisp.org/newLISP_in_21_minutes.html

Any other book about LISP will rather confuse you than help when you are using/learning newLISP. You may also want to read this page to see the differences between newLISP and the older standards Common LISP and Scheme:

http://newlisp.org/index.cgi?page=Diffe ... ther_LISPs

Lutz

cormullion
Posts: 2038
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W
Contact:

Post by cormullion »

newLISP has macros - they're not as weird as Common Lisp's though, judging from the look of them. Try searching the docs and this forum for define-macro.

(I don't understand them yet... ;-))

Fanda
Posts: 253
Joined: Tue Aug 02, 2005 6:40 am
Contact:

Post by Fanda »

Hi _ex_!

To translate code from Common LISP to newLISP, you need to know both languages, so I wouldn't start with that. Learn newLISP first and then you can try to guess what's going on in Common LISP :-)

This is my guess ;-)

Code: Select all

(define (describe-path path)
  (append '(there is a) (list (path 1)) '(going) (list (path 0)) '(from here.)))

Code: Select all

> (describe-path '(west door garden))
(there is a door going west from here.)
Fanda

_ex_
Posts: 23
Joined: Wed Aug 23, 2006 3:17 pm
Location: Peru

Post by _ex_ »

Ok sorry I think I was misunderstood.
Actually I could *understand* the tutorial (so brave of me to say that ;)
I just was asking how to translate the above Common Liso code to its newLISP version for you more expert users.

Fanda
Posts: 253
Joined: Tue Aug 02, 2005 6:40 am
Contact:

Post by Fanda »

Little different approach (substitution instead of appending):

Code: Select all

(define (describe-path2 path)
  (letex (_thing_ (path 1) _direction_ (path 0))
    '(there is a _thing_ going _direction_ from here.)))
In this version, keyword 'path' can also be used in letex if we need/want to:
(not used right now)

Code: Select all

(define (describe-path3) 
  (letex (_thing_ (args 0 1) _direction_ (args 0 0)) 
    '(there is a _thing_ going _direction_ from here.)))
Fanda

_ex_
Posts: 23
Joined: Wed Aug 23, 2006 3:17 pm
Location: Peru

Post by _ex_ »

Thank you Fanda :)
now that you mention it...
I DON´T HAVE MY LETEX!! LOL
*runs to download develpment version*

Locked