Skip to content

Commit

Permalink
Add List<T>.shifted function
Browse files Browse the repository at this point in the history
  • Loading branch information
Zomis committed Apr 4, 2021
1 parent cfbf11c commit 42ad5f8
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
package net.zomis.games.common

fun <T: Any> T.toSingleList(): List<T> = listOf(this)
fun <T> List<T>.shifted(steps: Int): List<T> {
require(steps >= 0)
require(steps < this.size)
return this.subList(steps, this.size) + this.subList(0, steps)
}

0 comments on commit 42ad5f8

Please sign in to comment.