且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在Haskell中获取列表的最后一个元素的最快方法

更新时间:2023-11-10 08:04:58

last and init will do the job just fine for a one-off. However they are both O(n), so if you need to manipulate both ends of a list often, as you seem to imply, you might want to consider using Data.Sequence instead, which supports O(1) insertion and removal of items at both ends.