Created
July 10, 2019 17:28
-
-
Save thedeemon/c5ea5fb521776ff4b2a6de77f2d92b44 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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