Created
April 13, 2018 10:20
-
-
Save kmdsbng/b621a1898f75fef1b0cc542f6cfb8000 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
tailrec fun <T, R> Iterable<T>.mapWithConsIter(result: Cons<R>, src: Iterator<T>, cb: (T) -> R): List<R> { | |
if (!src.hasNext()) { | |
return result | |
} | |
val e = src.next() | |
return mapWithConsIter(Cons<R>(cb(e), result), src, cb) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment