[plt-scheme] Pattern matching help

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

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)))


I want the  item identifier bound by the match-let to be a value in a
second match's first clause.How do i do that?

It should became like this:

 (match-let ([(list item rest-of-lst ...) (list (list 'eat 'cake))])
  (match (list (list 'some 'dah) (list 'hmm 'ta) (list 'life 'sucks))
    ((list (list 'eat 'cake) next-item rest-items ...)  ; item-> (list
'eat 'cake)
     (printf "~a: ~a\n"  item (cons next-item rest-items)))

    (_ 'false)))


Thanks


Posted on the users mailing list.