How can I write reverse by foldr efficiently in Haskell?

前端 未结 5 1490
误落风尘
误落风尘 2021-02-06 01:44

Note that the trivial solution

reverse a = foldr (\\b c -> c ++ [b] ) [] a

is not very efficient, because of the quadratic growth in complex

5条回答
提交回复
热议问题