[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] matchable egg usage question
From: |
Alan Post |
Subject: |
Re: [Chicken-users] matchable egg usage question |
Date: |
Sat, 29 Jan 2011 21:33:56 -0700 |
On Sun, Jan 30, 2011 at 12:28:00PM +0900, Alex Shinn wrote:
> On Sun, Jan 30, 2011 at 12:09 PM, Alan Post <address@hidden> wrote:
> >
> > Alex, will you explain what I'd doing wrong here using
> > tree searching patterns?
> >
> > (pretty-print (map
> > (match-lambda
> > (('foo *** '(bar 1)) #t)
> > (_ #f))
> > '((foo (bar 1))
> > (foo (a (bar 1)))
> > (foo (a (b (bar 1))))
> > (foo (a (b (c (bar 1))))))))
> >
> > Only the first form |(foo (bar 1))| is returning #t here.
> > The remaining forms return #f. I would expect all of them
> > to return true, based on my naive understanding of the ***
> > operator.
>
> 'foo has to match every step of the path. It sounds
> like you want
>
> ('foo (_ *** '(bar 1)))
>
Wonderful! This is working for the test cases I sent, but it
doesn't seem to work when I have a list where the first element
is also a list:
(pretty-print (map
(match-lambda
(('foo (_ *** '(bar 1))) #t)
(_ #f))
'((foo (bar 1))
(foo (a (bar 1)))
(foo (a (b (bar 1))))
; these three fail
(foo ((a (b (bar 1)))))
(foo (a ((b (bar 1)))))
(foo (a (b ((bar 1))))))))
I don't understand why the last three examples fail to match the
pattern here. I would expect them all to match, or if that weren't
true I'd expect all but the last one to match.
-Alan
--
.i ko djuno fi le do sevzi