私はこのコードを持っています:
type Matrice = [[String]]
matr =[[" - "," 0 "," - "],[" - "," - "," - "],[" - "," - "," - "]]
changeValue :: Matrice ->Int->Int->Matrice
changeValue mat x y = [
if ((mat !! x) !! y) /= " - "
then mat
else do (replaceNth y " P " xs)
| xs <- (mat !! x)
]
replaceNth :: 関数 位置の値 ' - ' を (' P ') に置き換えます
replaceNth :: Int -> String -> [String] -> [String]
replaceNth n newVal (x:xs)
| n == 0 = newVal:xs
| otherwise = x:replaceNth (n-1) newVal xs
マトリックスで「 - 」を「 P 」にする各ケースを変更したい
しかし、それは機能していません。私は常にこのエラーがあります:
couldn't match type [char] with char