chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] matchable egg usage question


From: Alex Shinn
Subject: Re: [Chicken-users] matchable egg usage question
Date: Sun, 30 Jan 2011 13:40:35 +0900

On Sun, Jan 30, 2011 at 1:33 PM, Alan Post <address@hidden> 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]