Skip to content

Instantly share code, notes, and snippets.

@sslotsky sslotsky/crash.re
Created Jan 7, 2019

Embed
What would you like to do?
let insert = site => {
let (leftSide, rightSide) = sites^ |> List.partition(s => s.left <= site.left);
let (overlap, rest) = rightSide |> List.partition(s => s.left <= site.right);
let rightSide = switch(overlap) {
| [] => [site, ...rightSide]
| _ => let closest = overlap->List.rev->List.hd; [site->connectRight(closest), ...rest]
}
let site = rightSide->List.hd;
let leftSide = switch (leftSide->List.rev) {
| [s, ...rest] when s.right >= site.left => [s->connectRight(site), ...rest]->List.rev
| _ => leftSide->List.append([site])
};
sites := switch (rightSide->List.tl) {
| tail => leftSide->List.append(tail)
| exception Failure(_) => leftSide
};
};
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.