Created
January 19, 2015 18:33
-
-
Save miguel-vila/bc99b8a70c4f79cd697a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
def makeFigure(size: Int, spaces: Int, characters: Int, spacesModifier: Int, charactersModifier: Int): String = { | |
val charsValsStream = Stream.iterate(characters, size)(chars => chars + charactersModifier) | |
val spacesValsStream = Stream.iterate(spaces, size)(spaces => spaces + spacesModifier) | |
(charsValsStream zip spacesValsStream).foldLeft(new StringBuilder) { case (builder,(characters,spaces)) => | |
builder append (" " * spaces) append ("*" * characters) append "%n".format() | |
}.toString() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment