1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
@BEGIN_BEFORE_4_07_0@
let vec_to_seq length get v =
let length = length v in
let rec aux i () =
if i = length then Stdcompat__seq.Nil
else
let x = get v i in
Stdcompat__seq.Cons (x, aux (i + 1)) in
aux 0
let vec_to_seqi length get v =
let length = length v in
let rec aux i () =
if i = length then Stdcompat__seq.Nil
else
let x = get v i in
Stdcompat__seq.Cons ((i, x), aux (i + 1)) in
aux 0
@END_BEFORE_4_07_0@
@BEGIN_BEFORE_4_05_0@
let option_find f x =
try Some (f x)
with Not_found -> None
let option_fail f x =
try Some (f x)
with Failure _ -> None
let option_invalid f x =
try Some (f x)
with Invalid_argument _ -> None
exception Predicate_not_found
let pickle_predicate_not_found p x =
try
p x
with Not_found ->
raise Predicate_not_found
@END_BEFORE_4_05_0@
@BEGIN_BEFORE_4_03_0@
let rec uniq_rev_append cmp l accu =
match l with
| [] -> accu
| [item] -> item :: accu
| hd :: (hd' :: _ as tl) ->
if cmp hd hd' = 0 then uniq_rev_append cmp tl accu
else uniq_rev_append cmp tl (hd :: accu)
@END_BEFORE_4_03_0@
|