Skip to content

Commit 42ad5f8

Browse files
committed
Add List<T>.shifted function
1 parent cfbf11c commit 42ad5f8

File tree

1 file changed

+5
-0
lines changed
  • games-core/src/main/kotlin/net/zomis/games/common

1 file changed

+5
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
package net.zomis.games.common
22

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

0 commit comments

Comments
 (0)