P Varga
P Varga

Reputation: 20229

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' ... :)

Upvotes: 4

Views: 476

Answers (1)

Sean
Sean

Reputation: 62472

You can use a match guard to add a condition:

match x with 
| t when t >= 'a' && t <= 'k' -> 1

Upvotes: 6

Related Questions