[ create a new paste ] login | about

Link: http://codepad.org/oeHElsPM    [ raw code | output | fork ]

OCaml, pasted on Nov 4:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
open Batteries_uni

let get_list n r =
  let process_coord (x,y) =
    let fx,fy = (float x, float y) in
    let base_angle = atan2 fy fx in
    let delta_angle = r /. (sqrt (fx*.fx +. fy*.fy)) |> asin in
    [(base_angle -. delta_angle, 1); (base_angle +. delta_angle, -1)] |> List.enum in
  let coords_enum = [? (x, y) | x <- 0 -- n; y <- 0 -- x ; x *x + y*y < n * n; x * x + y * y>0 ?] in
  let res = coords_enum |> Enum.map process_coord |> Enum.concat |> Array.of_enum in
  Array.sort compare res;
  res;;

let () = (get_list 10000 0.02) |> Array.length |> Printf.fprintf stdout "%d" ;;


Output:
1
2
Line 9, characters 21-22:
Syntax error


Create a new paste based on this one


Comments: