Skip to content

Instantly share code, notes, and snippets.

@ro6
Created August 16, 2017 13:50
Show Gist options
  • Save ro6/5b86efe4c4bee147205122d8d6368086 to your computer and use it in GitHub Desktop.
Save ro6/5b86efe4c4bee147205122d8d6368086 to your computer and use it in GitHub Desktop.
"_" should ignore in match, but compiler tries to capture and fails with "cannot capture "_", variable not defined"
be behave() =>
if _has_food then //heading home
_current_cell.get_is_home(
Promise[Bool].>next[None](
{(is_home: Bool)(ant = recover tag this end) =>
if is_home then
ant.access({(ant': Ant ref) =>
ant'.drop_food()
ant'.turn(4)})
else
_current_cell.query_neighbors_ahead(
_direction,
Promise[(CellInfo, CellInfo, CellInfo)].>next[None](
{(cells: (CellInfo, CellInfo, CellInfo)) =>
match cells
| (_, (let ahead_cell: Cell, _, _, None, true), _) =>
//TODO better occupancy check, should consult occupant if present
ahead_cell.request_move(
ant,
Promise[Bool].>next[None](
{(did_move: Bool) =>
did_move} iso))
end
} iso))
end} iso))
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment