Created
May 2, 2011 07:10
-
-
Save jrudolph/951254 to your computer and use it in GitHub Desktop.
nocps Generator
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
class Generator[T](body: => T) { | |
def generate(i: Int): Seq[T] = (0 until i) map (_ => body) | |
} | |
object Main { | |
def main(args: Array[String]) { | |
def genInt = util.Random.nextInt | |
def genBool = util.Random.nextBoolean | |
case class A(i: Int, b: Boolean) | |
val genA = new Generator(A(genInt, genBool)) | |
genA generate 10 foreach println | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment