[m-users.] Pattern matching in Mercury

Roger Qiu roger.qiu at polycademy.com
Sun Oct 26 17:19:56 AEDT 2014


Hello everybody,

According to this: 
http://stackoverflow.com/questions/7466833/mercury-determinism-and-pattern-matching

Mercury does not pattern match in a linear order. I'm used to the 
pattern matching in Erlang, and it works by going by the first one that 
matches. However this does not work in Mercury, all the clauses need to 
be fully mutually exclusive.

The pattern matching on the arguments are not sufficient enough to setup 
mutually exclusive clauses. I have an idea that perhaps guard statements 
on the clauses might help these situations, and allow one to retain 
"clause-like" switches instead of defaulting on the if-then-else 
pattern. What do you think?

Thanks,
Roger

-- 
Founder of Matrix AI
http://matrix.ai/
+61420925975




More information about the users mailing list