]> matita.cs.unibo.it Git - pkg-cerco/acc.git/blob - src/ASM/Util.ml
Imported Upstream version 0.2
[pkg-cerco/acc.git] / src / ASM / Util.ml
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 []