Skip to content

Instantly share code, notes, and snippets.

@thedeemon thedeemon/tox.ml
Created Jul 10, 2019

Embed
What would you like to do?
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
You can’t perform that action at this time.