Hello :)

2013/11/30 Mark H Weaver <m...@netris.org>

>
> Although it's not in the manual, we already have this.  It's called
> 'match-lambda' and 'match-lambda*' in (ice-9 match).  'match-lambda'
> creates a procedure that accepts a single argument, and does pattern
> matching on that argument.  'match-lambda*' matches the entire argument
> list.
>
> (use-modules (ice-9 match))
> (define f (match-lambda ((a . b) (+ a b))))
> (f (cons 3 4)) => 7
>
>
My implementation actually does use the match-lambda* macro.
The whole idea was to extend the possibilities of the "regular"
lambda, just like the (ice-9 curried-definitions) extends the way
the define form can be used. For the time being, the notation
(lambda ((x y)) ...) is illegal, although I believe that it's quite
comprehensible and natural, and using it doesn't decrease
the understandability of the program, while making it more
concise.

Reply via email to