From: ludo@gnu.org (Ludovic Courtès)
To: Dan Gildea <gildea@cs.rochester.edu>
Cc: guile-user@gnu.org
Subject: Re: (define* (((f a) b) c) ...)
Date: Tue, 15 Mar 2011 09:37:55 +0100 [thread overview]
Message-ID: <87pqpsn5i4.fsf@gnu.org> (raw)
In-Reply-To: <20110313154926.GA14534@e15.cs.rochester.edu> (Dan Gildea's message of "Sun, 13 Mar 2011 11:49:26 -0400")
Hi,
Dan Gildea <gildea@cs.rochester.edu> 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’.
prev parent reply other threads:[~2011-03-15 8:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-13 15:49 (define* (((f a) b) c) ...) Dan Gildea
2011-03-15 8:37 ` Ludovic Courtès [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87pqpsn5i4.fsf@gnu.org \
--to=ludo@gnu.org \
--cc=gildea@cs.rochester.edu \
--cc=guile-user@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).