ハノイの塔の再帰関数を実装しようとしています。ハノイの塔を実装するときのHaskellエラー
アルゴリズムは次のとおりです。
Move n−1 disks from peg AA to peg C using peg B as intermediate storage.
Move the nth disk from peg A to peg B,
Move n−1 disks from peg C to peg BB using peg A as intermediate storage.
Eample:
hanoi 2 "a" "b" "c" =
[("a","c"), ("a","b"), ("c","b")]
これは私の実装
hanoi :: Integer -> Peg -> Peg -> Peg -> [Move]
hanoi x "a" "b" "c"
| x <= 0 = []
| x == 1 = [("a", "b")]
| otherwise = (hanoi (x-1) "a" "c" "b") ++ [("a", "b")] ++ (hanoi (x-1) "c" "b" "a")
である私はエラーを得たがthere is un-exhausted pattern
と述べました。 どうすれば解決できますか?
引数を引用符で囲む必要はありません。ここで、彼らはすべきではありません。 –