type 'a seq = ('a -> unit) -> unit let enum high k = for i = 1 to high do k i done [@@inline always] let sum s = let n = ref 0 in s (fun x -> n := !n + x); !n [@@inline always] let filter pred seq k = seq (fun x -> if pred x then k x) [@@inline always] let map f seq k = seq (fun x -> k (f x)) [@@inline always] let high = 1000 * 1000 * 100 let res = enum high |> filter (fun x -> x mod 2 = 0) |> map (( * ) 2) |> sum let _ = Printf.printf "%d\n" res