Created
April 20, 2015 04:49
-
-
Save gzm55/c716e3c7497b90ff48d7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
def from(initial: Stream[(Block, List[Move])], | |
explored: Set[Block]): Stream[(Block, List[Move])] = initial.headOption.map { | |
case (block, _) if done(block) => initial.head #:: from(initial.tail, explored) | |
case (block, history) => | |
val newMoreBlocks = newNeighborsOnly(neighborsWithHistory(block, history), explored) | |
val newExploredBlocks = Set(block.left, block.down, block.right, block.up).filter(_.isLegal).filterNot(done) | |
(block, history) #:: from(initial.tail ++ newMoreBlocks, explored | newExploredBlocks) | |
}.getOrElse(Stream()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
fix unneeded tail evaluation