HEX
Server: Apache
System: Windows NT MAGNETO-ARM 10.0 build 22000 (Windows 10) AMD64
User: Michel (0)
PHP: 7.4.7
Disabled: NONE
Upload Files
File: C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rouge-3.26.1/lib/rouge/demos/fsharp
(* Binary tree with leaves car­rying 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