Created
August 16, 2017 13:50
-
-
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"
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
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