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 mut_point = { mutable x : float; mutable y : float; }
- let iters2_mut 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 begin
- p.x <- x *. x -. y *. y +. xc;
- p.y <- 2.0 *. x *. y +. yc;
- aux (count+1) p
- end
- end in
- aux 0 {x=xc;y=yc}
- (* 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