Here's a difficult extension I would love to see (although it's a bit
off the topic of currying): define/lazy and lazy, analogous to your
define/curry and curry. The difficult one is lazy, in fact, I think it
might be impossible.

BTW I also wrote a compose macro which behaves similarly to Haskell's
".", i.e. you can write in "point-free style". I can post it if you
want (you can probably just write one yourself). It would fit well
with such tools as curry and cut.

On Wed, May 27, 2009 at 5:25 PM, Ramana Kumar <[email protected]> wrote:
> Oh sorry I see you export curry too, so you can have anonymous ones.
>
> On Wed, May 27, 2009 at 5:24 PM, Ramana Kumar <[email protected]> wrote:
>> anonymous curried procedures?
>>
>> also, is your curry better than my case-lambda approach? yours is
>> about the same amount of code, and possibly more efficient... I don't
>> know
>>
>> On Wed, May 27, 2009 at 5:20 PM, Derick Eddington
>> <[email protected]> wrote:
>>> On Tue, 2009-05-26 at 18:36 -0500, Eduardo Cavazos wrote:
>>>> Hello,
>>>>
>>>> Here's a simple procedure:
>>>>
>>>> (define (subtract-from n)
>>>>     (lambda (m)
>>>>       (- n m)))
>>>>
>>>> subtract-from is essentially a two parameter '-' which is curried, left
>>>> to right.
>>>>
>>>> I don't recall a traditional/defacto way to express this. Any ideas or
>>>> suggestions?
>>>
>>> I have my (xitomatl curry) library (pasted below) which supports "rest"
>>> arguments and applying any number of arguments at a time:
>>>
>>>> (import (xitomatl curry))
>>>> (define/curry (f a b c . r)
>>>    (apply + a b c r))
>>>> (f 1 2 3 4)
>>> 10
>>>> ((f 1 2) 3 4 5 6)
>>> 21
>>>> (((f 1) 2) 3)
>>> 6
>>>>
>>>
>>> I just made it when I was bored, so now I'm wondering if I could enhance
>>> it in any ways...?
>>>
>>> --
>>> : Derick
>>> ----------------------------------------------------------------
>>>
>>>
>>> (library (xitomatl curry)
>>>  (export
>>>    define/curry
>>>    curry)
>>>  (import
>>>    (rnrs)
>>>    (only (xitomatl define) define/?)
>>>    (only (xitomatl predicates) positive-integer?))
>>>
>>>  (define-syntax define/curry
>>>    (lambda (stx)
>>>      (syntax-case stx ()
>>>        [(_ (name a ... . r) . body)
>>>         (and (identifier? #'name)
>>>              (positive? (length #'(a ...))))
>>>         #`(define name
>>>             (curry
>>>               (lambda (a ... . r) . body)
>>>               #,(length #'(a ...))))])))
>>>
>>>  (define/? (curry proc [n positive-integer?])
>>>    (lambda args
>>>      (let ([len (length args)])
>>>        (if (>= len n)
>>>          (apply proc args)
>>>          (curry
>>>            (lambda more (apply proc (append args more)))
>>>            (- n len))))))
>>> )
>>>
>>>
>>>
>>
>

Reply via email to