Task

Find and display the sum of elements that are below the main diagonal of a matrix.

The matrix should be a square matrix.



 ───   Matrix to be used:   ───


     [[1,3,7,8,10],
      [2,4,16,14,4],
      [3,1,9,18,11],
      [12,14,17,18,20],
      [7,1,3,9,5]] 



=LAMBDA(isUpper,
    LAMBDA(matrix,
        LET(
            nCols, COLUMNS(matrix),
            nRows, ROWS(matrix),
            ixs, SEQUENCE(nRows, nCols, 0, 1),
            x, MOD(ixs, nCols),
            y, QUOTIENT(ixs, nRows),
 
            IF(nCols=nRows,
                LET(
                    p, LAMBDA(x, y,
                        IF(isUpper, x > y, x < y)
                    ),
 
                    IF(p(x, y), 
                        INDEX(matrix, 1 + y, 1 + x), 
                        0
                    )
                ),
                "Matrix not square"
            )
        )
    )
)