我试图制作调用子序列的递归函数,但我遇到了一些错误。
我的代码:
recursive 1 list = subsequences list
recursive n list = subsequences (recursive (n-1) list)
错误:
Occurs check: cannot construct the infinite type: a1 ~ [a1]
Expected type: [a1]
Actual type: [[a1]]
Relevant bindings include
recursive :: a -> t -> [[a1]] (bound at p.hs:6:1)
In the first argument of ‘subsequences’, namely
‘(recursive (n - 1) list)’
In the expression: subsequences (recursive (n - 1) list)
你能帮我解决这个问题或找到另一种方法来调用子序列n次吗?
对不起,我的英语不好