elp with Newlisp

Q&A's, tips, howto's
Locked
gaD-
Posts: 2
Joined: Fri Jun 06, 2003 4:02 am

elp with Newlisp

Post by 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
Posts: 1390
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany
Contact:

Post by HPW »

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

Locked