I have some code which is designed to replace a value in a list
replaceNth n newVal (x:xs) | n == 0 = newVal:xs | otherwise = x:replaceNth (n-1) newVal xs
Using your existing definition:
ghci> let arg = [[3,3,3,3,3],[3,3,3,3,3],[3,3,3,3,3]] ghci> replaceNth 1 (replaceNth 3 2 (arg !! 1)) arg [[3,3,3,3,3],[3,3,3,2,3],[3,3,3,3,3]] ghci>
To refactor it into a function:
replaceMthNth m n v arg = replaceNth m (replaceNth n v (arg !! m)) arg