-(!!?) matrix (i, j)
- | i < 0 || j < 0 = Nothing
- | i > (nrows matrix) - 1 = Nothing
- | j > (ncols matrix) - 1 = Nothing
- | otherwise = Just $ matrix !!! (i,j)
+(!!?) matrix idx =
+ ifoldl2 f Nothing matrix
+ where
+ f k l found cur = if (k,l) == idx then (Just cur) else found