source: Deliverables/D4.1/Util.ml @ 557

Last change on this file since 557 was 454, checked in by sacerdot, 9 years ago

CSC + Nicolas + Dominic:

1) back-porting of changes by Nicolas from the compiler
2) new file ASMCosts to compute the cost of labels
3) several changes here and there to implement 2)

File size: 545 bytes
RevLine 
[128]1let ($) f x = f x
[130]2;;
[128]3
[130]4let (<*>) f g x = f (g x)
5;;
6
[131]7let flip f a b = f b a
8;;
9
[135]10let fst (a, b) = a
11;;
12
13let snd (a, b) = b
14;;
15
[137]16let rec pad v i l =
17  match i with
18    0 -> l
19  | n -> v :: (pad v (i - 1) l)
20;;
21
[128]22let char_list_of_string s =
23  let str_length = String.length s in
24  let rec aux s l buff =
25    if l = str_length then
26      buff
27    else
28      aux s (l + 1) ((String.get s l)::buff)
29  in
30    List.rev $ aux s 0 []
[454]31
32let fold_lefti f =
33 let rec aux i acc =
34  function
35     [] -> acc
36   | he::tl -> aux (i+1) (f i acc he) tl
37 in
38  aux 0
39;;
40
Note: See TracBrowser for help on using the repository browser.