Created
March 17, 2012 21:34
-
-
Save gsimard/2065481 to your computer and use it in GitHub Desktop.
More functional way of doing that
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
var entitiesMap = Map[Int,Entity]() | |
private val randEntityId = new scala.util.Random(0) | |
def uniqueEntityId() = { | |
var id = 0; | |
do { | |
id = randEntityId.nextInt() | |
} while (entitiesMap.contains(id)) | |
id | |
} | |
(last (take-while #(contains entitiesMap %) (iterate nextInt 0))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment