我正在尝试编译此函数:
fff [] _ = []
fff (x:xs) ys
| r == [] = xs1
| otherwise ys ++ xs1
where r = filter (x<) ys
xs1 = fff xs ys
但是我收到了这个错误:
Test.hs:14:4:输入`where'
时解析错误失败,模块加载:无。
任何帮助解决它?
谢谢,
安。
答案 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