added a helper method for converting functions into iterators (which have all the various standard library APIs on them)

This commit is contained in:
James Strachan
2012-03-25 08:10:17 +01:00
parent 85bf6dc5a7
commit a194764657
3 changed files with 43 additions and 0 deletions
@@ -0,0 +1,22 @@
package iterators
import kotlin.*
import kotlin.test.*
import kotlin.util.*
import org.junit.Test
class FunctionIteratorTest {
Test fun iterateOverFunction() {
var count = 3
val iter = iterate<Int> {
count--
if (count >= 0) count else null
}
val list = iter.toList()
assertEquals(arrayList(2, 1, 0), list)
}
}