Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let iters1 max_iter xc yc =
- let rec aux count x y =
- if count = max_iter then max_iter else begin
- if x *. x +. y *. y >= 4.0 then count else
- aux (count+1) (x *. x -. y *. y +. xc) (2.0 *. x *. y +. yc)
- end in
- aux 0 xc yc
- type point = { x : float; y : float }
- let iters2 max_iter pc =
- let {x=xc;y=yc} = pc in
- let rec aux count p =
- if count = max_iter then max_iter else begin
- let {x;y} = p in
- if x *. x +. y *. y >= 4.0 then count else
- aux (count+1) {p with x = x *. x -. y *. y +. xc; y = 2.0 *. x *. y +. yc}
- end in
- aux 0 {x=0.;y=0.}
- * use with "-pp camlp4of" *)
- DEFINE UNBOX(e) = (e +. 0.)
- let iters6 max_iter xc_boxed yc_boxed =
- let xc = UNBOX xc_boxed in
- let yc = UNBOX yc_boxed in
- let x = ref (UNBOX xc) in
- let y = ref (UNBOX yc) in
- let count = ref 0 in
- for i = 1 to max_iter do
- if !x *. !x +. !y *. !y >= 4.0 then raise Exit;
- x := (!x *. !x -. !y *. !y +. xc);
- y := (2.0 *. !x *. !y +. yc);
- done; !count
Advertisement
Add Comment
Please, Sign In to add comment