Scott Nimrod
Scott Nimrod

Reputation: 11595

How can I OR union cases?

I referenced this link. However, I still don't see how I can OR the following union cases:

match count with
| x when x < 2 -> grid |> setCell { X=x; Y=y; State=Dead }
| x when x > 3 -> grid |> setCell { X=x; Y=y; State=Dead }
| _            -> grid

I want to do this:

match count with
| x when x < 2
| x when x > 3 -> grid |> setCell { X=x; Y=y; State=Dead }
| _            -> grid

Is this possible?

Upvotes: 1

Views: 87

Answers (2)

Functional_S
Functional_S

Reputation: 1159

With a boolean OR operator ||

match count with
| x when x > 3 || x < 2 -> grid |> setCell { X=x; Y=y; State=Dead }
| _                     -> grid

Upvotes: 4

Mark Seemann
Mark Seemann

Reputation: 233125

How about inverting the matches?

match count with
| 1
| 2 -> grid
| _ -> grid |> setCell { X=count; Y=y; State=Dead }

Upvotes: 3

Related Questions