guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Matching lambdas proposal


From: Panicz Maciej Godek
Subject: Re: Matching lambdas proposal
Date: Sat, 30 Nov 2013 20:43:31 +0100

Hello :)

2013/11/30 Mark H Weaver <address@hidden>

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

[Prev in Thread] Current Thread [Next in Thread]