[1..10]
[1,10,2,9,3,8,4,7,5,6,6,5,7,4,8,3,9,2,10,1]
我试过这个
fon(x:y:xs) =reverse (x:xs)
fun (x:y:xs) = x : (fon xs)
答案 0 :(得分:3)
怎么样:
interweave :: [a] -> [a]
interweave zs = f zs (reverse zs)
where f xs ys = concat $ zipWith (\ x y -> [x,y]) xs ys
例如
λ> interweave [1..10]
[1,10,2,9,3,8,4,7,5,6,6,5,7,4,8,3,9,2,10,1]
答案 1 :(得分:1)
因为这看起来像是家庭作业,所以我会提供一些提示。
您需要原始列表和反向列表。尝试像
这样的东西foo :: [a] -> [a]
foo xs = bar xs (reverse xs)
bar :: [a] -> [a] -> [a]
...