Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fun robPoint () =
- let
- val maxX = ref ~1
- val maxY = ref ~1
- val x = ref ~1
- val y = ref ~1
- fun move(i,j) =
- (
- x := !x + i;
- y := !y + j;
- if !x <= !maxX andalso !y <= !maxY andalso !x >= 0 andalso !y >= 0 then
- (i,j)
- else raise RobolOutOfGrid
- )
- fun start(i,j) =
- (x := i ; y := j;(i,j))
- fun get(i,j) =
- (!x,!y)
- fun setMax(i,j) =
- (maxX := i ; maxY := j;(i,j))
- fun dispatch("move") = move
- | dispatch("start") = start
- | dispatch("setMax") = setMax
- | dispatch(_) = get
- in
- dispatch
- end;
- val robolPoint = robPoint();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement