Pattern matching on arrays
Subject: Pattern matching on arrays
Newsgroups: gmane.comp.lang.ocaml.beginners
Date: 2008-12-01 00:33:31 GMT
Ocaml offers pattern matching on arrays, but it doesn't seem to behave
like list pattern-matching.
For instance, the following, where 'x' is the first element and '_' is
the rest of the array doesn't work:
# match [|1;2;3|] with [|x;_|] -> x;;
Characters 0-33:
match [|1;2;3|] with [|x;_|] -> x;;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Warning P: this pattern-matching is not exhaustive.
Here is an example of a value that is not matched:
[| |]
Exception: Match_failure ("", 100, -408).
Is there some way to do this in Ocaml?
-deech
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch format to Traditional
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe
__,_._,___
RSS Feed