let containsAs (s : string) = String.filter (fun c -> c = 'a') s |> String.length let numOfStringsContainingAs (str : string []) = str |> Array.map (fun s -> containsAs(s)) |> Array.sum printfn "%A" (numOfStringsContainingAs [|"ciao";"come";"va"|]) printfn "%A" (numOfStringsContainingAs [|"ciaaao";"come";"va"|]) let numeroPippo x = if x%3 = 1 then Some(x) else None let parolaPippo x = if x = "pippo" then Some(x) else None let isPippo (x : option<'a>) = match x with | Some(x) -> true | None -> false printfn "%b" (isPippo(numOfStringsContainingAs [|"a";"a";"a";"a"|] |> numeroPippo)) printfn "%b" (isPippo(numOfStringsContainingAs [|"a";"a";"a"|] |> numeroPippo)) printfn "%b" (isPippo(parolaPippo("pipo"))) printfn "%b" (isPippo(parolaPippo("pippo")))