newLISP Fan Club

Forum => newLISP newS => Topic started by: gaD- on June 05, 2003, 09:05:32 PM

Title: Help with Newlisp
Post by: gaD- on June 05, 2003, 09:05:32 PM
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
Title:
Post by: Lutz on June 06, 2003, 03:42:08 PM
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