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".
declare
fun{MatchAll X}
case X of _ then true
else false
end
end
X=nil ---------->true
X=1|2|nil|1 --->true
Combining _ for real world pattern matching (_ by itself doesn't make sense)
declare
fun{MatchIt X}
case X of _|1 then true
else false
end
end
X=nil|1 ---------->true
X=(1|2|nil)|1 --->true
X=1|2|nil|1------>false
Is this the expected behaviour?
Thank you, I'm understanding a lot of things :-)
Regards
2009/2/13 Raphael Collet <[email protected]>
> On Fri, Feb 13, 2009 at 2:42 PM, Quirino Zagarese <
> [email protected]> wrote:
>
>> Thank you very much Raphael,
>> I though only procedures could use parameters in that way.
>>
>
> This is true. But functions in Oz are defined as procedures, that's why it
> works ;-)
>
> Now it's all clearer.
>> Then what about matching whatever#true? Is there a way to do that(i.e. a
>> character like % in SQL)?
>
>
> The identifier '_' matches anything, for instance:
>
> case Result of _#true then ... end
>
> Cheers,
> raph
>
>
>
> _________________________________________________________________________________
> mozart-users mailing list
> [email protected]
> http://www.mozart-oz.org/mailman/listinfo/mozart-users
>
--
Quirino Zagarese
LaszloItalia Founder (www.laszloitalia.org)
Software Development Manager - Galilaeus s.r.l.
_________________________________________________________________________________
mozart-users mailing list
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users