This works: :(de myf (F L) (F L)) -> myf : (let (L 99) (myf '((x) (+ (car x) `L)) (1 2))) -> 100
The key there is the back-quote (`) before the L to force evaluation See the doc section on 'Read-Macros' http://software-lab.de/doc/ref.html#macro-io /Lindsay On Tue, Feb 7, 2017 at 7:55 PM, pd <eukel...@gmail.com> wrote: > Hello, > > I wonder if there is any way to bind a free symbol in a lambda in order to > pass the lambda to a defined function (for example) > > What I want to do is something like this: > > (de myf (f l) (f l)) > > (let l 99 (myf '((x) (+ (car x) l)) (1 2))) > > I want it to return 100 but it fails with an error (1 2) number expected > > this is because free symbol l in lambda ((x) (+ (car x) l)) is not bind by > let as pretended because of quoting of lambda > > In other words, I think the problem is quoting avoids let binding as in: > > (setq f (let n 10 '((x) (+ x n)))) -> ((x) (+ x n)) > > but I want it to return -> ((x) (+ x 10)) > > or using the typicall example: > > (de adder (n) '((x) (+ x n))) -> ((n) '((x) (+ x n))) > > so (adder 1) should return ((x) (+ x 1)) but it returns ((x) (+ x n)) > > Is there any way to manage this? Something similar to "expand" in newlisp > will do the job: > > newlisp: > (define (badadder n) (lambda (x) (+ x n))) > (badadder 3) -> (lambda (x) (+ x n)) > (define (adder n) (expand (lambda (x) (+ x n)) 'n)) > (adder 3) -> (lambda (x) (+ x 3)) > > The fist example in newlisp will be: > > (define (myf f l) (f l)) > > (let ((l 99)) (myf (lambda (x) (+ (first x) l)) '(1 2))) > > which fails for same reason picolisp fails but in newlisp the solution is: > > (define (myf f l) (f l)) > > (let ((l 99)) (myf (expand (lambda (x) (+ (first x) l)) 'l) '(1 2))) -> > 100 > > > thanks > > >