From: ············@gmail.com
Subject: higher-order-function library?
Date: 
Message-ID: <1186524102.531286.254750@57g2000hsv.googlegroups.com>
Is there an open source lisp project with the fp utilities like curry
conjoin and disjoin?

Thanks in advance,

Andrew

From: ···········@gmail.com
Subject: Re: higher-order-function library?
Date: 
Message-ID: <1186538923.230954.240960@g4g2000hsf.googlegroups.com>
On 8 Sie, 00:01, ·············@gmail.com" <············@gmail.com>
wrote:
> Is there an open source lisp project with the fp utilities like curry
> conjoin and disjoin?
>
> Thanks in advance,
>
> Andrew

Example implementation:

(defun curry (fn &rest arguments)
  (let* ((arguments (copy-list arguments))
	 (last (last arguments)))
    (lambda (&rest args)
      (nconc last args)
      (apply fn arguments))))

(defun compose (f g)
  (lambda (&rest args) (funcall f (apply g args))))

(defun conjoin (&rest functions)
  (lambda (&rest args)
    (every (lambda (arg) (every (lambda (a) (funcall a arg))
				functions))
	   args)))

(defun disjoin (&rest functions)
  (lambda (&rest args)
    (some (lambda (arg) (some (lambda (a) (funcall a arg))
			    functions))
	 args)))

I think it's better to include them directly in one file in your
project, rather than using external libraries - they are too small to
justify library dependency.

Pawe  Zawal
From: ············@gmail.com
Subject: Re: higher-order-function library?
Date: 
Message-ID: <1186542052.630133.324570@g4g2000hsf.googlegroups.com>
Thanks for those implementations.  I should have mentioned that before
I posting, I searched this group for "curry."  Doing so reveals that
lots of people have their own versions of curry that by and large
perform as expected but vary a bit with respect to &rest args and use
of compiler macros.  In my op, I was just wondering if there was some
de facto standard or canonical version of these common functions.  It
looks like Alexandria purports to provide just that -- it's stated
goal is, "to reduce duplication of effort and improve portability of
Common Lisp code."

Thanks for the pointers Luis and Pawe.

-- Andrew
From: ···········@gmail.com
Subject: Re: higher-order-function library?
Date: 
Message-ID: <1186556410.929643.105270@r34g2000hsd.googlegroups.com>
On 8 Sie, 05:00, ·············@gmail.com" <············@gmail.com>
wrote:
> Thanks for those implementations.  I should have mentioned that before
> I posting, I searched this group for "curry."  Doing so reveals that
> lots of people have their own versions of curry that by and large
> perform as expected but vary a bit with respect to &rest args and use
> of compiler macros.  In my op, I was just wondering if there was some
> de facto standard or canonical version of these common functions.  It
> looks like Alexandria purports to provide just that -- it's stated
> goal is, "to reduce duplication of effort and improve portability of
> Common Lisp code."
>
> Thanks for the pointers Luis and Pawe.
>
> -- Andrew

I'm sorry, there's an error in curry function, correct version is:

(defun curry (fn &rest arguments)
  (let* ((arguments (copy-list arguments))
	 (last (last arguments)))
    (if arguments
	(lambda (&rest args)
	  (setf (cdr last) args) ;;error was here
	  (apply fn arguments))
	fn)))

Pawel Zawal
From: Luís Oliveira
Subject: Re: higher-order-function library?
Date: 
Message-ID: <m1lkcmby3c.fsf@deadspam.com>
·············@gmail.com" <············@gmail.com> writes:
> Is there an open source lisp project with the fp utilities like curry
> conjoin and disjoin?

Alexandria has those.  <http://common-lisp.net/project/alexandria/>

-- 
Luís Oliveira
http://student.dei.uc.pt/~lmoliv/