code: public static ToIntFunction<IntTuple> lexicographicalIndexer(
          IntTuple size)
      {
          Objects.requireNonNull(size, "The size is null");
          IntTuple reversedProducts =
              IntTupleFunctions.exclusiveScan(
                  IntTuples.reversed(size), 1, (a, b) -> a * b, null);
          IntTuple sizeProducts = IntTuples.reverse(reversedProducts, null);
          return indices -> IntTuples.dot(indices, sizeProducts); 
      }
docs: Creates a function that maps multidimensional indices to 1D indices.
  The function will create consecutive 1D indices for indices that
  are given in lexicographical order.
  
  @param size The size of the array to index
  @return The indexer function
  @throws NullPointerException If the given size is <code>null</code>.