OCaml: Matching with any negative
Posted
by nicotine
on Stack Overflow
See other posts from Stack Overflow
or by nicotine
Published on 2010-04-29T21:20:03Z
Indexed on
2010/04/29
22:37 UTC
Read the original article
Hit count: 405
Is there a way to get pattern matching to match my value with any negative number? It does not matter what the negative number is I just need to match with any negative.
I have accomplished what I want with this simple code:
let y = if(n < 0) then 0 else n in
match y with
0 -> []
| _ -> [x] @ clone x (n - 1)
But I want to eliminate that if
statement and just get it to check it as another case in the match
statement
© Stack Overflow or respective owner