elp with Newlisp

Q&A's, tips, howto's

elp with Newlisp

Postby gaD- » Fri Jun 06, 2003 4:07 am

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 :(
Posts: 2
Joined: Fri Jun 06, 2003 4:02 am

Postby HPW » Fri Jun 06, 2003 5:35 am

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.
Posts: 1374
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany

Return to newLISP in the real world

Who is online

Users browsing this forum: No registered users and 2 guests