This is the mail archive of the
kawa@sources.redhat.com
mailing list for the Kawa project.
SRFI 26: Macros for partial parameterisation
- From: Jocelyn Paine <popx at ifs dot org dot uk>
- To: kawa at sources dot redhat dot com
- Date: Fri, 23 Aug 2002 06:35:05 +0100 (BST)
- Subject: SRFI 26: Macros for partial parameterisation
I've just been playing around with Sebastian Egner's SRFI 26, "Notation
for Specializing Parameters without Currying" ( http://srfi.schemers.org/srfi-26/ ).
It provides macros that construct new functions from old by fixing some of
the parameters. Nothing that can't be done with lambda, of course, but
much more concise.
Examples:
(cut cons 1 <>) = (lambda (x) (cons 1 x))
Fixes the first parameter to cons.
(cut cons <> 1) = (lambda (x) (cons x 1))
Fixes the second parameter.
In general, cut takes the name of the function followed by a sequence of
values and "slot markers" indicated by the <> symbol. Parameter positions
marked by <> are left open, while the others are filled in by the values:
#|kawa:5|# ( (cut list 1 <> 2 <> 3) 'a 'b)
(1 a 2 b 3)
If anyone is collecting SRFIs for distribution with Kawa, you may like to
know that the library loaded and ran the author's test cases without any
modification, and also seems to work when compiled; I don't see anything
in the code that I wouldn't expect Kawa to handle.
Jocelyn Paine
http://www.ifs.org.uk/~popx/
+44 (0)7768 534 091