structure Dict :> DICT = BinarySearchTree; datatype square = Peg | Hole; type board = square Dict.dict; structure Dir = struct datatype direction = East | NorthEast | NorthWest | West | SouthWest | SouthEast fun increment (East) = (1,0) | increment (NorthEast) = (0,1) | increment (NorthWest) = (~1,1) | increment (West) = (~1,0) | increment (SouthWest) = (0,~1) | increment (SouthEast) = (1,~1) fun exists p = p East orelse p NorthEast orelse p NorthWest orelse p West orelse p SouthWest orelse p SouthEast end; fun initialize (i,j) b = next (i,j) (Dict.insert (b,((i,j),Peg))) and next (0,0) b = b | next (i,0) b = initialize (i-1,5-i) b | next (i,j) b = initialize (i,j-1) b; val initialBoard = initialize (4,0) (Dict.empty);