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

Started by realist, January 12, 2009, 11:32:30 AM

Previous topic - Next topic

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)
Mehmet Köse

Lutz

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