Page 1 of 1

Casting SPELs in Lisp (newLISP)

Posted: Tue Sep 05, 2006 9:06 pm
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.

Posted: Tue Sep 05, 2006 9:35 pm
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

Posted: Tue Sep 05, 2006 10:37 pm
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... ;-))

Posted: Wed Sep 06, 2006 3:23 am
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

Posted: Wed Sep 06, 2006 3:47 am
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.

Posted: Wed Sep 06, 2006 3:52 am
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

Posted: Wed Sep 06, 2006 4:23 am
by _ex_
Thank you Fanda :)
now that you mention it...
I DON“T HAVE MY LETEX!! LOL
*runs to download develpment version*