Created
June 11, 2012 08:56
-
-
Save mandubian/2909163 to your computer and use it in GitHub Desktop.
Iteratee.mkString
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
def mkString[E](start: String, sep: String, end: String): Iteratee[E, String] = { | |
def step(s: String, isFirst: Boolean)(input: Input[E]): Iteratee[E, String] = { | |
input match { | |
case Input.EOF => Done(s + end, Input.EOF) | |
case Input.Empty => Cont(step(s, isFirst)) | |
case Input.El(e) => { val s1 = if(isFirst) { s + e.toString } else { s + sep + e.toString }; Cont[E, String](i => step(s1, false)(i)) } | |
} | |
} | |
Cont(step(start, true)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment