scala - Exit for loop as soon as condition satisfied -
the following code hangs repl:
( { <- 1 1000000 j <- 2 1000000 if * == j } yield -> j ).take(1)
it seems expression eagerly evaluated. solutions?
i'd turn stream:
( { <- stream.range(1, 1000000) j <- stream.range(2, 1000000) if * == j } yield -> j ).take(1)
Comments
Post a Comment