On Sun, Jan 30, 2011 at 12:28:00PM +0900, Alex Shinn wrote:
> On Sun, Jan 30, 2011 at 12:09 PM, Alan Post <alanp...@sunflowerriver.org> 
> 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

_______________________________________________
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users

Reply via email to