Casting SPELs in Lisp (newLISP)

Started by _ex_, September 05, 2006, 02:06:00 PM

Previous topic - Next topic

_ex_

Well I found this excellent newbie tutorial



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



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



(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

#1
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">http://newlisp.org/introduction-to-newlisp.pdf

 or

http://newlisp.org/newLISP_in_21_minutes.html">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=Differences_to_Other_LISPs">http://newlisp.org/index.cgi?page=Diffe ... ther_LISPs">http://newlisp.org/index.cgi?page=Differences_to_Other_LISPs



Lutz

cormullion

#2
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

#3
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 ;-)


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

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


Fanda

_ex_

#4
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

#5
Little different approach (substitution instead of appending):


(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)


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


Fanda

_ex_

#6
Thank you Fanda :)

now that you mention it...

I DONĀ“T HAVE MY LETEX!!    LOL

*runs to download develpment version*