On Sun, Jan 30, 2011 at 1:33 PM, Alan Post <alanp...@sunflowerriver.org> wrote: > > 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.
Because it searches for patterns where the head of the tree at each step along the path matches _, and the leaf matches '(bar 1). The head is not searched as a potential leaf. That's a somewhat arbitrary decision, but works well with the intended use case which is matching SXML (where the head is always a symbol). -- Alex _______________________________________________ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users