summaryrefslogtreecommitdiff
path: root/ocaml-binary-annot/camlp4/examples/test_macros.ml
blob: 1e1b172b5d012d015101e350fd6c2fab2e948f81 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
(* DEFINE F(x, y, z) = x + y * z;; *)
(* F(F(1, 2, 3), 4, 5);; *)

(* !+ (1, 2, 3, 4);; *)

(* foldl(( + ), 1, 2, 3, 4);; *)
(* foldr(cons, 1, 2, 3, []);; *)

let cons x xs = x :: xs;;

def_foldl ( !+ ) ( + );;
def_foldr ( !:: ) cons;;

!+ (1, 2, 3, 4);;
!:: (1, 2, 3, []);;