>> In the ML example I showed earlier: >> fun len([]) = 0 >> | len(h::t) = len(t) + 1 >> ordering is crucial: As long as the argument is not empty, both cases >> match, so the language is defined to test the clauses in sequence. >> My intuition is that people will often want to define category tests >> to be done in a particular order. There is no problem with such ordering >> as long as all of the tests are specified together. Martin> What does "not empty" mean in this context? "not []"? Does h::t match [] Martin> or does [2] match []? Why is the ordering crucial? In Haskell: Martin> f [] = 0 Martin> f (x:xs) = 1 + f xs Martin> is totally equivalent with: Martin> f (x:xs) = 1 + f xs Martin> f [] = 0 I'm sorry, you're right. In this particular example, there is no overlap, so order doesn't matter. However, the general point still stands: ML patterns are order-sensitive in cases where there is overlap. -- Andrew Koenig, ark@research.att.com, http://www.research.att.com/info/ark
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4