Skip to content

Instantly share code, notes, and snippets.

@thedeemon
Created July 10, 2019 17:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thedeemon/c5ea5fb521776ff4b2a6de77f2d92b44 to your computer and use it in GitHub Desktop.
Save thedeemon/c5ea5fb521776ff4b2a6de77f2d92b44 to your computer and use it in GitHub Desktop.
open Batteries
type point = { x : int; y : int }
let f from_y to_y from_x to_x =
let a = (from_y --^ to_y/2) |> Enum.map (fun y -> {x=from_x; y=y}) in
let b = (to_y/2 --^ to_y) |> Enum.map (fun y -> {x=to_x; y=y}) in
Enum.append a b |> Array.of_enum;;
let g from_y to_y from_x to_x =
let t = to_y/2 in
Array.init (to_y - from_y) (fun i -> let y = i + from_y in if y < t then {x=from_x; y=y} else {x=to_x;y=y});;
let arr = g 20000000 80000000 1 2 in
(*Array.iter (fun p -> Printf.printf "[%d %d] " p.x p.y) arr;*)
let p = arr.(Array.length arr - 1) in
Printf.printf "\n[%d %d] \n" p.x p.y;;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment