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
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
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
·············@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/