Last change
on this file since 1102 was
454,
checked in by sacerdot, 10 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
|
Line | |
---|
1 | let ($) f x = f x |
---|
2 | ;; |
---|
3 | |
---|
4 | let (<*>) f g x = f (g x) |
---|
5 | ;; |
---|
6 | |
---|
7 | let flip f a b = f b a |
---|
8 | ;; |
---|
9 | |
---|
10 | let fst (a, b) = a |
---|
11 | ;; |
---|
12 | |
---|
13 | let snd (a, b) = b |
---|
14 | ;; |
---|
15 | |
---|
16 | let rec pad v i l = |
---|
17 | match i with |
---|
18 | 0 -> l |
---|
19 | | n -> v :: (pad v (i - 1) l) |
---|
20 | ;; |
---|
21 | |
---|
22 | let 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 [] |
---|
31 | |
---|
32 | let 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.