Help with Newlisp

Notices and updates
Locked
gaD-
Posts: 2
Joined: Fri Jun 06, 2003 4:02 am

Help 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

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

use 'first' and 'rest' instead od car and cdr, to access individual elements after the first use 'nth' for sub lists use 'sublist'. See the newLISP manual for details.

Also, I am not sure what your code does, but newLISP has a lot of higher level list manipulating functions, which probably can make your code much faster and easier to read.

Lutz

Locked