Email list hosting service & mailing list manager


Cut and the operators mu and nu Jens Axel Søgaard 05 Apr 2006 20:33 UTC

The specifications of mu and nu are:

   (mu <expr> ...)          => (lambda (f) (f <expr> ...))
   (nu <expr> ... <exprn>)  => (lambda (f) (apply f <expr> ... <exprn>))
   The <exprn> should be a list.

These are indeed useful operations. So useful that we already have
a srfi for them, namely srfi-26.

(cut <> <expr> ...)
                            => (lambda (f) (f <expr> ...))
(cut apply <> <expr> ... <exprn>)
                            => (lambda (f) (apply <expr> ... <exprn>))

Example:

   Welcome to DrScheme, version 301.12-svn5apr2006.
   Language: Pretty Big (includes MrEd and Advanced Student).
   > (require (lib "26.ss" "srfi"))
   > (define m (cut <> 1 2))
   > (m list)
   (1 2)
   > (define n (cut apply <> 1 '(2 3)))
   > (n list)
   (1 2 3)

--
Jens Axel Søgaard
<http://www.scheme.dk/planet/>