Given a type
type C = Circle of int | Rectangle of int * int
and a collection
let l = [ Circle(1); Circle(2); Rectangle(1,2)]
I want to handle only circles
let circles = l |> List.filter(fun x-> match x with
| Circle(l) -> true
| _ -> false)
But my circles are still of type C, thus I cannot do
for x in circles do
printf "circle %d" x.??
I have to do
for x in circles do
match x with
| Circle(l) -> printf "circle %d" l
| _ -> ())
seems wrong..