0
我写了这个代码,它是关于两个字符串是另一个每个字谜:错误 - 在输入语法错误(意外符号“大”)
anagram :: String->String->Bool
anagram w1 w2 = anagram1 x1 x2
where
y1 = break w1
y2 = break w2
x1 = quicksort y1
x2 = quicksort y2
anagram1 :: [String]->[String]->Bool
anagram1 (h1:t1)(h2:t2)
| h1!=h2 = False
| h1==h2 = anagram1 t1 t2
| otherwise = True
我找到了快速排序有http://c2.com/cgi/wiki?QuickSortInHaskell
代码quicksort :: [String]->[String]
quicksort [] = []
quicksort (h:t) = quicksort small ++ (h : quicksort(large))
where
small = [y | y <- t, y <= h]
large = [y | y <- t, y > h]
break :: String->[String]
break s = map (\c -> [c]) s
当我运行它,我采取错误输入语法错误(意外符号“大”)。
为什么我错了?
[无法重现]( http://coliru.stacked-crooked.com/a/97a4e24a70de478d)。你可能打破了你的缩进。 – 2015-04-01 10:16:55