Help with Newlisp

Started by gaD-, June 05, 2003, 09:05:32 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

Lutz

#1
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