source: extracted/untrusted/ocamlList.ml @ 2738

Last change on this file since 2738 was 2738, checked in by sacerdot, 7 years ago

Porting the graph colouring stuff from the untrusted prototype to the extracted
code.

File size: 532 bytes
Line 
1let rec rev_append l1 l2 =
2  match l1 with
3    [] -> l2
4  | a :: l -> rev_append l (a :: l2)
5
6let rev l = rev_append l []
7
8let find_all p =
9  let rec find accu = function
10  | [] -> rev accu
11  | x :: l -> if p x then find (x :: accu) l else find accu l in
12  find []
13
14let filter = find_all
15
16let rec map f = function
17    [] -> []
18  | a::l -> let r = f a in r :: map f l
19
20let rec iter f = function
21    [] -> ()
22  | a::l -> f a; iter f l
23
24let rec fold_right f l accu =
25  match l with
26    [] -> accu
27  | a::l -> f a (fold_right f l accu)
Note: See TracBrowser for help on using the repository browser.