[plt-scheme] Pattern matching help

From: Veer (diggerrrrr at gmail.com)
Date: Thu Feb 12 10:37:36 EST 2009

It works now  , thanks for the help Sam TH and Noel Welsh .


On Thu, Feb 12, 2009 at 8:52 PM, Sam TH <samth at ccs.neu.edu> wrote:
> On Thu, Feb 12, 2009 at 10:04 AM, Veer <diggerrrrr at gmail.com> wrote:
>> Hello,
>>
>> Code :
>>
>> (match-let ([(list item rest-of-lst ...) (list (list 'eat 'cake))])
>>  (match (list (list 'some 'dah) (list 'hmm 'ta) (list 'life 'sucks))
>>    ((list item next-item rest-items ...)
>>     (printf "~a: ~a\n"  item (cons next-item rest-items)))
>>
>>    (_ 'false)))
>>
>
> The easiest way to do this is:
>
> (match-let ([(list item rest-of-lst ...) (list (list 'eat 'cake))])
>  (match (list (list 'some 'dah) (list 'hmm 'ta) (list 'life 'sucks))
>   [(list (? (lambda (e) (equal? e item))) next-item rest-items ...)
>    (printf "~a: ~a\n"  item (cons next-item rest-items))
>   [_ 'false]))
>
> Hope that helps,
> --
> sam th
> samth at ccs.neu.edu
>


Posted on the users mailing list.