moi VARIANT type 'a lazy_list = Cons of 'a * 'a lazy_list Lazy.t | Nil;;
let rec element m n =
(n+.m)/.2.;;
let f x = x*.x;;
let rec poisk2 k m n =
let i = element m n in
let z = f i in
Cons (i, lazy (if z<=k then (poisk2 k i n) else
poisk2 k m i)) ;;
(*let primer = [|1;3;5;7;9;12|];;
print_int (Array.length (primer)-1);;
poisk 7 primer;;
*)
let rec vibor f n l =
if (n>0) then
( match l with
Cons (l1,ls)-> f l1; vibor f (n-1) (Lazy.force ls)
|Nil -> []) else [];;
let rec vicheslit f e n l =
match l with
Cons (l1,ls) -> print_float l1;print_string "\n"; if abs_float (n-.(f l1))>e then (vicheslit f e n (Lazy.force ls))
|Nil->print_string "ki";;
vicheslit (fun x -> x*.x) 0.2 52. (poisk2 52. 0. 76.376)
конечно не самый лучший вариант, но все же ...