函数定义中的Haskell解析错误

时间:2014-04-23 01:05:33

标签: haskell

我正在尝试编译此函数:

fff [] _ = []
fff (x:xs) ys
   | r == [] = xs1
   | otherwise ys ++ xs1
   where r = filter (x<) ys 
         xs1 = fff xs ys

但是我收到了这个错误:

  

Test.hs:14:4:输入`where'

时解析错误      

失败,模块加载:无。

任何帮助解决它?

谢谢,
安。

1 个答案:

答案 0 :(得分:2)

=后,您错过了所需的otherwise

顺便说一句,r == []最好由更一般的null r替换。

试试这个:

fff [] _ = []
fff (x:xs) ys
    | r == [] = xs1
    | otherwise = ys ++ xs1
    where r = filter (x<) ys 
          xs1 = fff xs ys