This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
(* Binary tree with leaves carrying an integer. *)
|
||||
type Tree = Leaf of int | Node of Tree * Tree
|
||||
|
||||
let rec existsLeaf test tree =
|
||||
match tree with
|
||||
| Leaf v -> test v
|
||||
| Node (left, right) ->
|
||||
existsLeaf test left
|
||||
|| existsLeaf test right
|
||||
|
||||
let hasEvenLeaf tree =
|
||||
existsLeaf (fun n -> n % 2 = 0) tree
|
||||
Reference in New Issue
Block a user