Created
June 4, 2016 14:28
-
-
Save voddan/0df034b7f241ea8c5dc066726778cad0 to your computer and use it in GitHub Desktop.
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
abstract class CircularList<E, H: Circular<E>>(val size: Int) : Circular<List<E>> { | |
protected abstract val state: List<H> // state.size == size | |
override fun inc() { | |
state.forEach { | |
it.inc() | |
if(! it.isZero()) return | |
} | |
} | |
override fun isZero() = state.all {it.isZero()} | |
override fun hasNext() = state.any {it.hasNext()} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment