Hi Quirino, I think I understand the source of your confusion (sorry if I'm wrong). (I saw David Bremner answered this when writing this email, but send it anyway)
> I was just trying to understand why the expression _|1 does not match > 4|3|2|1 even if _ matches 4|3|2. >> Ok, I did some tests and I think I got it. >> The _ seems to exhibit two different behaviours: if you use it in pattern >> matching by itself, its semantic is "anything"; >> if you combine it with symbols like | or #, its semantic is "any symbol". You think of matching as of textual matching, like matching of regular expressions. You should avoid this kind of thinking in case pattern matching. Case matching is a structural matching. Just in case, to be clear 1) [4] is actually a shorthand for 4|nil 2) 4|nil is a shorthand for '|'(4 nil) 3) | operator is right associative, so 4|3|2 is 4|(3|2) , which in turn(by the 2.) is '|'(4 '|'(3 2)) Structurally, 4|3|2 is a pair of head 4 and tail (3|2), so when you try to match it with _|2 it does not work. You could match it on 4|_ or 4|(3|_) or equivalently on 4|3|_ Hope it helps, Oleg _________________________________________________________________________________ mozart-users mailing list [email protected] http://www.mozart-oz.org/mailman/listinfo/mozart-users
