And then there's this... (From "Lisp 1.5 Programmer's Manual".. McCarthy...
)...

# This function gives the result of substituting the S-expression
# x for all occurrences of the atomic symbol y in the S-expression z.
(de subst (X Y Z)
   (cond
      ((= Y Z) X)
      ((atom Z) Z)
      (T (cons (subst X Y (car Z)) (subst X Y (cdr Z)))) ) )

which lets you write things like

: (de myf (N) (subst N 'N '((x) (+ x N))))
-> myf
: (myf 1)
-> ((x) (+ x 1))
: ((myf 1) 99)
-> 100
: (myf '(* 3 33))
-> ((x) (+ x (* 3 33)))
: ((myf '(* 3 33)) 1)
-> 100

You could build that out... picolisp ... (= code data)
but at the end of the day you would probably end up  with 'curry'. (
http://software-lab.de/doc/faq.html#closures)..  with a job environment to
manage scope, etc

/Lindsay

But I feel more comfortable with the other you provided
>
> : (de adder (N) (list '(x) (list '+ 'x (eval 'N))))
>
> because I feel more in control of generated lambda
>
> thanks!
>

Reply via email to