Thank you. I'll check some evening this week and see if this subject is
adequately covered on the wiki, and try to incorporate this in if it is not.

On 02/21/2017 10:13 AM, Alexander Burger wrote:
> Hi Christopher,
> 
>> (de make-adder (N) (list '(X) (list '+ 'X N)))
>>
>> That works, but I was wondering if there was some more readable way to
>> do it.
> 
> Well, the standard candidate for that purpose is 'curry' (though we learned 
> that
> this function name is a bit unlucky ;)
> 
>    (de make-adder (N)
>       (curry (N)
>          (X) (+ X N) ) )
> 
> In this call, 'N' is kept in a closure, allowing it to be changed while the
> generated function runs:
> 
>    (make-adder 7)
>    -> ((X) (job '((N . 7)) (+ X N)))
> 
> This is here not necessary, thus 'curry' allows you to tell it when
> values are constant by using pattern variables, here '@N':
> 
>    (de make-adder (@N)
>       (curry (@N)
>          (X) (+ X @N)) )
> 
>    (make-adder 7)
>    -> ((X) (+ X 7))
> 
> 
> Another option (in addition to your direct 'list'ing, is 'fill'
> 
>    (de make-adder (N)
>       (fill '((X) (+ X N)) 'N) )
> 
>    (make-adder 7)
>    -> ((X) (+ X 7))
> 
> ♪♫ Alex
> 

-- 
Christopher Howard, Computer Assistant
Alaska Satellite Internet
3239 La Ree Way, Fairbanks, AK 99709
907-451-0088 or 888-396-5623 (toll free)
fax: 888-260-3584
mailto:christop...@alaskasi.com
http://www.alaskasatelliteinternet.com
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe

Reply via email to