[plt-scheme] lambda-apply-values
On 21/11/2008, at 23:07, Stephen De Gabrielle wrote:
> Hi,
>
> something I seem to often do is use list as structures, (and have
> lists of these)
>
> eg
>
> #lang scheme
> (define people '(("Guy" 40 man) ("Maddona" 50 woman)))
>
> I am often doing something like;
>
> (map (λ (person)
> (let ((name (car person))
> (age (car person))
> (gender (car person)))
> (blah-fn name age gender)
> ) people)
(map (match-lambda (((list name age gender) (blah-fn name age
gender))) people)
or there-abouts.
Match is, imo, grand.
Per some of the other comments, I try not to use lists as structures
per-se, but when pulling information out of XML files I find that
that's just how it is, and match is just brilliant for turning them
back into structs or function arguments.
Cheers,
Andrew