Hi Alex, > However, a function call is about the most expensive thing in PicoLisp. It > interprets the parameter list (X), saves the old value of X, evaluates (not X) > and restores the value of X.
(de null..) was really unnecessary here :) I just wrote it for completeness as part of the book exercise and after my earlier confusion regarding 'NIL, NIL, '()... Nice to know about 'def' when I need a bit of syntax sugar though ! I am starting to get the hang of the basics here I think. I've been spending a bit of time bench'ing some of the recursive functions and trying to eliminate the recursion or use a built-in function, as you have often shown. # my append : (de cuius (X Y) (cond ((not X) Y) (T (cons (car X) (cuius (cdr X) Y))))) : (bench (let (N ()) (for X 10000 (setq N (cuius N '(NIL)))) (length N))) 2.983 sec -> 10000 # ...with nond : (de cuius (X Y) (nond (X Y) (NIL (cons (car X) (cuius (cdr X) Y))))) : (bench (let (N ()) (for X 10000 (setq N (cuius N '(NIL)))) (length N))) 2.644 sec -> 10000 # ... neither of the above are even close in performance to ... # append : (bench (let (N ()) (for X 10000 (setq N (append N '(NIL)))) (length N))) 0.548 sec -> 10000 # cons : (bench (let (N '()) (for X 10000 (setq N (cons NIL N))) (length N))) 0.000 sec -> 10000 # conc : (bench (let (N (list)) (for X 9999 (conc N (list))) (length N))) 0.067 sec -> 10000 # -- or -- : (bench (let (N ()) (setq N (need 10000)) (length N))) 0.000 sec -> 10000. Interestingly, I was expecting conc to be faster then (setq..(cons..). At least in this case, it was not. /Lindsay