Created
July 7, 2015 12:29
-
-
Save ripla/9cb2f3616d80866a303c to your computer and use it in GitHub Desktop.
Creating infinite streams from a function
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
//Get a new Stream that always calls the given function when a new value | |
//is needed. | |
def stream(): Source[Int, Unit] = | |
Source(() => Iterator.continually(createValue())) | |
//Just an example, could be anything | |
def createValue(): Int = Random.nextInt() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment