[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: (define* (((f a) b) c) ...)
From: |
Ludovic Courtès |
Subject: |
Re: (define* (((f a) b) c) ...) |
Date: |
Tue, 15 Mar 2011 09:37:55 +0100 |
User-agent: |
Gnus/5.110013 (No Gnus v0.13) Emacs/23.3 (gnu/linux) |
Hi,
Dan Gildea <address@hidden> writes:
> In guile 2.0, I need to use "define*" to define second-order functions
> such as:
>
> (define* ((f a) b) ...)
You should use (ice-9 curried-definitions) for this (see NEWS), and...
> But define* doesn't work for higher-order functions, or for more
> complicated definitions of second-order functions, such as:
>
> (define* (((f a) b) c) ...)
>
> (define* ((f #:optional a) b) ...)
it also works for optional/keyword arguments:
--8<---------------cut here---------------start------------->8---
scheme@(guile-user)> (use-modules(ice-9 curried-definitions))
scheme@(guile-user)> (define* ((f #:optional a) b) (list a b))
scheme@(guile-user)> ((f) 2)
$2 = (#f 2)
scheme@(guile-user)> ((f 1) 2)
$3 = (1 2)
--8<---------------cut here---------------end--------------->8---
Hope this helps,
Ludo’.