f#: Tidy same_iterators_p a little.
authorMark Wooding <mdw@distorted.org.uk>
Wed, 18 Nov 2009 13:41:23 +0000 (13:41 +0000)
committerMark Wooding <mdw@distorted.org.uk>
Wed, 18 Nov 2009 13:41:23 +0000 (13:41 +0000)
Use Option.isNone rather than a multiline pattern match, and use a
pattern guard to reduce failure cases.

f#-fringe.fs

index 33e8f4d..45d011b 100644 (file)
@@ -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.