alex cole
01/09/2021, 12:12 AMval x = object[5,3]
What type of data is the 5, 3 representing.ephemient
01/09/2021, 12:13 AMoperator fun get(i: Int, j: Int)
would get i=5 j=3
alex cole
01/09/2021, 12:14 AMoperator fun Object.get(value: SomeDataType){}
ephemient
01/09/2021, 12:15 AMoperator fun get
then you can't write object[i, j]
fun get(value: SomeDataType)
, you can't call get(5, 3)
alex cole
01/09/2021, 12:15 AMephemient
01/09/2021, 12:15 AMoperator fun get(vararg indices: Int)
then there would be an IntArray created to pass the varargsalex cole
01/09/2021, 12:19 AMephemient
01/09/2021, 12:20 AMobject[1]
from object[(1, )]
alex cole
01/09/2021, 12:22 AMephemient
01/09/2021, 12:26 AMoperator fun get(range: IntRange)
object[1..5]
alex cole
01/09/2021, 12:27 AMobject[1, 3..5]
ephemient
01/09/2021, 12:28 AMoperator fun <T> Array2D<T>.get(x: Int, y: Int): T
operator fun <T> Array2D<T>.get(x: Int, y: IntRange): Array1D<T>
operator fun <T> Array2D<T>.get(x: IntRange, y: Int): Array1D<T>
operator fun <T> Array2D<T>.get(x: IntRange, y: IntRange): Array2D<T>
isn't too many overloads to deal withalex cole
01/09/2021, 12:29 AMephemient
01/09/2021, 12:29 AMalex cole
01/09/2021, 12:31 AMephemient
01/09/2021, 12:31 AMoperator fun ArrayND.get(vararg indices: Any): Any
would allow for any mix, with the logic inside attempting to cast to Int or IntRange, but it can't be done in a type-safe manner. the caller will also have to perform an unsafe castalex cole
01/09/2021, 12:31 AMephemient
01/09/2021, 12:32 AMobject[String, Object, List, Map, Array]
would compile.slice
property, perhaps) to achieve the rest, one dimension at a timealex cole
01/09/2021, 12:34 AMephemient
01/09/2021, 12:34 AMalex cole
01/09/2021, 12:35 AMephemient
01/09/2021, 12:41 AMobject[x, y, z]
0-D and object.slice[x][y..y][z].asArrayND()
, where
operator fun <T> ArrayND<T>.get(vararg indices: Int): T
val <T> ArrayND<T>.slice: Slice<T> get() = ...
operator fun <T> Slice<T>.get(index: Int): Slice<T>
operator fun <T> Slice<T>.get(index: IntRange): Slice<T>
alex cole
01/09/2021, 12:42 AMephemient
01/09/2021, 3:05 AMalex cole
01/09/2021, 3:07 AMephemient
01/09/2021, 3:08 AM.map()
etc? that would make sense, although it might be hard to find reasonable semantics for others like .filter()
alex cole
01/09/2021, 3:09 AM