Changeset 89 for Deliverables/D4.1/BitVectors.ml
 Timestamp:
 Sep 20, 2010, 11:48:03 AM (10 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

Deliverables/D4.1/BitVectors.ml
r88 r89 95 95 in 96 96 aux 1 (List.rev v) 97 98 let size_lookup = 99 function 100 `Four > 4 101  `Seven > 7 102  `Eight > 8 103  `Eleven > 11 104  `Sixteen > 16 105 106 let rec pow v p = 107 if p = 0 then 108 1 109 else 110 v * (pow v (p  1)) 111 112 let divide_with_remainder x y = (x / y, x mod y) 113 114 let rec aux i = 115 if i < 0 then 116 raise (Invalid_argument "Negative index") 117 else 118 let (d, r) = divide_with_remainder i 2 in 119 if (d, r) = (0, 0) then 120 [] 121 else if r = 0 then 122 false :: aux d 123 else 124 true :: aux d 125 126 let rec pad i l = 127 match i with 128 0 > l 129  n > false :: (pad (i  1) l) 130 131 let vect_of_int i size = 132 let big_list = List.rev (aux i) in 133 if List.length big_list > (size_lookup size) then 134 raise (Invalid_argument "Size not big enough") 135 else 136 let diff = (size_lookup size)  (List.length big_list) in 137 pad diff big_list 138
Note: See TracChangeset
for help on using the changeset viewer.