From 6bce693f147dfca5affdeb04f93a41b7ebd76bb9 Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Wed, 18 Nov 2009 13:41:23 +0000 Subject: [PATCH] f#: Tidy same_iterators_p a little. Use Option.isNone rather than a multiline pattern match, and use a pattern guard to reduce failure cases. --- f#-fringe.fs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/f#-fringe.fs b/f#-fringe.fs index 33e8f4d..45d011b 100644 --- a/f#-fringe.fs +++ b/f#-fringe.fs @@ -41,16 +41,11 @@ let list_iterator it = it |> fold_iterator (curry List.Cons) [] |> List.rev // Asnwer whether two iterators report the same items. let rec same_iterators_p ita itb = match next ita with - | None -> - match next itb with - | None -> true - | _ -> false + | None -> Option.isNone(next itb) | Some (a, ita) -> match next itb with - | None -> false - | Some (b, itb) -> - if a = b then same_iterators_p ita itb - else false + | Some (b, itb) when a = b -> same_iterators_p ita itb + | _ -> false ///-------------------------------------------------------------------------- /// Nodes and trees. -- 2.11.0