Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - realist

#1
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)