I had the idea of defining an operator that accepts a (possibly) multidimensional list and list of indices and returns an element. My attempt:
(!!!) xs [i] = xs !! i
(!!!) xs (cI : restI) = (xs !! cI) !!! restI
In retrospect, this obviously has a lot of problems. At first I could not understand the type signature, then I realized that in line 2 the type of the return value (xs !! cI) will constantly change and may not always be a list (at the last "iteration")
I realized that to use a multidimensional array using the standard index operator, you can simply link it like this:
[[1,2,3],[4,5,6],[7,8,9]] !! 1 !! 1 = 5
And I realized that this is very similar to a fold, so I tried:
(!!!) xxs inds = foldl (!!) xxs inds
or simply (!!!) = foldl (!!)
But I get the same error as my first attempt; that I'm trying to build an infinite type.
( )? , , .
, :
[[1,2,3],[4,5,6],[7,8,9]] !!! [1,1] = 5