Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Matching character ranges in F#

What is the equivalent of the OCaml:

match x with 
| 'a'..'k' -> 1
...

in F#?

(short of | 'a' | 'b' | 'c' ... :)

like image 836
ᅙᄉᅙ Avatar asked Oct 22 '25 19:10

ᅙᄉᅙ


1 Answers

You can use a match guard to add a condition:

match x with 
| t when t >= 'a' && t <= 'k' -> 1
like image 62
Sean Avatar answered Oct 24 '25 17:10

Sean



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!