Hi Kashyap, > Does this look like a reasonable way to create the "create-adder" function? > > (de create-adder Args > (let > (N (car Args) > Adder (intern (pack "add-" N)) > P > (list > 'de > Adder > '(X) > (list '+ N 'X) ) ) > (eval P) ) ) > > : (create-adder 10) > -> add-10 > : (add-10 20) > -> 30
Yes, but you can do it a little simpler by directly calling 'def': (de create-adder (N) (def (intern (pack "add-" N)) (list '(X) (list '+ N 'X)) ) ) Note also that I use (N), i.e. an evaluated argument, as this makes the function more general. Even simpler if you use 'curry': (de create-adder (@N) (def (intern (pack "add-" @N)) (curry (@N) (X) (+ @N X) ) ) ) It is especially simpler if the function body, which is here just (+ N X), is more complicated, because then the 'list'ing and 'cons'ing of the body would become very unreadable. > If I understand correctly, the "macro" capability of miniPicoLisp is not at > par with PicoLisp right? The 'macro' function of mini and normal PicoLisp is the same I think. ☺/ A!ex -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe