Haskell加密函数
我正在HASKELL中创建函数加密。这就是我目前所拥有的Haskell加密函数,haskell,Haskell,我正在HASKELL中创建函数加密。这就是我目前所拥有的 encipher :: Eq a => [a] -> [b] -> [a] -> [b] encipher _ _ [] = [] encipher xs ys (z:zs) = if f == [] then z:encipher xs ys zs else snd (head f) : (encipher xs ys zs) where t
encipher :: Eq a => [a] -> [b] -> [a] -> [b]
encipher _ _ [] = []
encipher xs ys (z:zs) = if f == []
then z:encipher xs ys zs
else snd (head f) : (encipher xs ys zs)
where t = zip xs ys
f = filter ((== z) . fst) t
p9tests = [encipher ['A'..'Z'] ['a'..'z'] "THIS" == "this"]
我用p9tests测试它。不确定我做错了什么。你的问题是缩进。
下的所有定义,其中
需要在同一级别缩进
因此,为了修复您的特定错误,您可以将f
缩进到上面一行的t
级别:
where t = zip xs ys
f = filter ((== z) . fst) t
或者你可以走另一条路,把t
带到f
的级别:
where
t = zip xs ys
f = filter ((== z) . fst) t
你的问题是什么?我得到了一个错误。我在f=filter(==z)上得到了一个错误。fst)t输入上的一个错误'f'是我得到的错误。我修复了这个错误,但仍然得到了错误。如果你有不同的错误,请发布不同的问题。另外,如果你遇到了一个错误,最好告诉帮助你的人这个错误到底是什么,这样他们就不用猜了。