Haskell尾函数的递归

时间:2016-04-06 22:24:37

标签: list haskell tail

我有这个功能

func1 :: Double -> [(Double,Double)] -> Maybe [(Double,Double)]
...............
func2 :: Double -> [(Double,Double)] -> [(Double,Double)]
func2 d [] =  []
func2 d list = 
  let dsegs1 = func1 d list
      dsegs2 = func2 d (tail list)
  in  fromJust dsegs1 ++ dsegs2

我希望在func2中实现的简单流程如下:

let x = func2 3.0 list
let y = func2 3.0 (tail list)
let z = func2 3.0 (tail (tail list))
let a = func2 3.0 (tail (tail (tail list)))

调用func2 n 次,直到它最后没有返回任何内容并结束xyz,...,{ {1}}。

我该怎么做?

1 个答案:

答案 0 :(得分:1)

看起来你想要map (func2 3.0) (tails list)