Add Input.findAll
This commit is contained in:
@@ -1,11 +1,16 @@
|
||||
package be.vandewalleh.aoc.utils.input
|
||||
|
||||
import org.intellij.lang.annotations.Language
|
||||
|
||||
class Input(private val value: String) {
|
||||
val text get() = value
|
||||
|
||||
val lines get() = Mapper(value.lines())
|
||||
val csv get() = Mapper(value.split(','))
|
||||
|
||||
fun findAll(@Language("RegExp") re: String): List<List<String>> =
|
||||
re.toRegex().findAll(value).map { it.groupValues.drop(1) }.toList()
|
||||
|
||||
class Mapper(val value: List<String>) {
|
||||
val ints get() = value.map { it.toInt() }
|
||||
val longs get() = value.map { it.toLong() }
|
||||
|
||||
Reference in New Issue
Block a user