On Wed, Feb 8, 2017 at 5:37 AM, Erik Gustafson <[email protected]> wrote:
> I think 'curry' is what you're looking for. Your 'adder' example could be > written as: > > : (de adder (@N) (curry (@N) (X) (+ X @N))) > -> adder > : (adder 3) > -> ((X) (+ X 3)) > : (doc 'curry) # for more info :) > > Hope that helps, > Erik > > this does the job and is exactly what I was looking for (together with the fill solution pointed afterwards) but I feel uncomfortable with the use of curry here due to my functional programming background... *I feel* curry to be a unfortunate name for that function because I expect curry to be a function that once applied to another function with n parameters it returns a chain of applying functions with exactly one argument, that is having: : (de sum (x y) (+ x y)) I expect a function named curry to behave this way: (curry 'sum) -> ((x) '((y) (+ x y))) # it is really pseudocode not actually picolisp code since returning a lambda quoted this way won't do the job or in classical lisp notation: (curry 'sum) -> (lambda (x) (lambda (y) (+ x y))) in a way you now can apply the curryfied sum partially: ((curry 'sum) 2) -> ((y) (+ 2 y)) or totally: ((curry 'sum) 3 4) -> 7 But picolisp curry function doesn't do that, it simply returns a lambda with 1 parameter having the other one properly substituted with its value thus making impossible to partially apply the returned function Is there anyway in picolisp to reproduce the functional curry behaviour? that's a sequence of lambdas allowing partial application
