newLISP Fan Club

Forum => Anything else we might add? => Topic started by: realist on January 12, 2009, 11:32:30 AM

Title: Hi everyone. I think I found a bug in docs.
Post by: realist on January 12, 2009, 11:32:30 AM
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)
Title:
Post by: Lutz on January 12, 2009, 12:13:27 PM
Yes, interpretation of a lambda list as a lambda (not a simple list) has a priority in this case.  Thanks for the correction.