newLISP Fan Club

Forum => newLISP in the real world => Topic started by: _ex_ on September 05, 2006, 02:06:00 PM

Title: Casting SPELs in Lisp (newLISP)
Post by: _ex_ on September 05, 2006, 02:06:00 PM
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



(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.
Title:
Post by: Lutz on September 05, 2006, 02:35:44 PM
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=Differences_to_Other_LISPs



Lutz
Title:
Post by: cormullion on September 05, 2006, 03:37:08 PM
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... ;-))
Title:
Post by: Fanda on September 05, 2006, 08:23:44 PM
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
Title:
Post by: _ex_ on September 05, 2006, 08:47:14 PM
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.
Title:
Post by: Fanda on September 05, 2006, 08:52:43 PM
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
Title:
Post by: _ex_ on September 05, 2006, 09:23:15 PM
Thank you Fanda :)

now that you mention it...

I DONĀ“T HAVE MY LETEX!!    LOL

*runs to download develpment version*