Hi everyone. I think I found a bug in docs.

For the Compleat Fan
Locked
realist
Posts: 1
Joined: Mon Jan 12, 2009 1:40 pm

Hi everyone. I think I found a bug in docs.

Post by realist »

Manipulate functions after definition

(define (double x) (+ x x))
→ (lambda (x) (+ x x))

(first double) → (x)
(last double) → (+ x x)

;; make a ''fuzzy'' double
(setf (double 1) '(mul (normal x (div x 10)) 2))

(double 10) → 20.31445313
(double 10) → 19.60351563

This example is in code patterns. Section "Functions as Data". This didn't work for me. But this one works:

(setf (nth 1 double) '(mul (normal x (div x 10)) 2))

If we use implicit indexing on functions, how can the interpreter know that we need indexing or running the function? (I am just guessing. I am not only new to newLISP, also new to programming)

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

Post by Lutz »

Yes, interpretation of a lambda list as a lambda (not a simple list) has a priority in this case. Thanks for the correction.

Locked