elp with Newlisp

Started by gaD-, June 05, 2003, 09:07:18 PM

Previous topic - Next topic

gaD-

Hi, I got a code that works fine on Lisp, but I can't make it work on Newlisp, I am very new to this language.



Here is the code for Lisp



(defun mymax (nums)

(cond ((= (length nums) 1) (car nums))

((> (car nums) (cadr nums))

(mymax (cons (car nums)

(cddr nums))))

(t (mymax (cdr nums)))))



I'd like to know how can it be done with Newlisp, specially the cadr, cddr and cdr functions.



Thanks in advance



Sorry for putting this in the news forum :(

HPW

#1
Hello gaD,



Seems that another one of the autolisp-community find his way to newlip.



Since some things are different in newlisp, some can be done by macros.



Lutz has provided some compatible functions in the past. (setq, foreach, repeat, defun) The functions cadr, cddr and cdr are not present. For "cdr" you can use "rest". For cadr use (first(rest x)). For cddr use (rest(rest x)).



You can look at init.lisp how you can define-macro and try it yourself or some other macro-master can help for such macro. Then you can expand newlisp to your known commands.



Hope this helps.
Hans-Peter