有些人帮我下面的功能,但是我需要它的反转意味着下面的输出将是我的函数的输入,下面的输入将是我函数的输出
ReturnAnInt
答案 0 :(得分:2)
我认为您正在寻找此功能的反转
conv = concat . f
where f [] = []
f (x:xs) = map (x+) xs : f xs
> conv [3,10,5]
[13,8,15]
> conv [2,5,15,34]
[7,17,36,20,39,49]
我发现了这样的事情。请注意,对于长度小于3的情况,无法做出独特的解决方案,处理这种情况......
solve x = (reverse . (h :) . map (subtract h) . map head . split') rx
where rx@(a:b:c:_) = reverse x
h = (a+b-c) `div` 2
> solve [7,17,36,20,39,49]
[2,5,15,34]
> solve [13,8,15]
[3,10,5]
你可以查看是否
conv . solve = solve . conv = id
分裂'在我的屏幕上向上滚动,它被定义为
split' = go 1
where go _ [] = []
go n x = take n x : go (n+1) (drop n x)