Skip to content

Instantly share code, notes, and snippets.

@jrudolph
Created May 2, 2011 07:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jrudolph/951254 to your computer and use it in GitHub Desktop.
Save jrudolph/951254 to your computer and use it in GitHub Desktop.
nocps Generator
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