Ocaml list code example
Example 1: print list ocaml
let rec print_list = function
[] -> ()
| e::l -> print_int e ; print_string " " ; print_list l
Example 2: list.fold_right
val fold_right : ('a -> 'b -> 'b) -> 'a list -> 'b -> 'b
let rec print_list = function
[] -> ()
| e::l -> print_int e ; print_string " " ; print_list l
val fold_right : ('a -> 'b -> 'b) -> 'a list -> 'b -> 'b