Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

Why does Haskell have Data.Sequence? Aren't (lazy) lists already the most general forward iterators possible (by virtue of being free monoids)?

share|improve this question
8  
They're more efficient for many operations, such as concatenation, especially on the right. –  AndrewC Jun 29 '13 at 13:34
11  
Another operation worth mentioning is index, which gets an i-th element in O(log(min(i,n-i))) time. For lists, the complexity is O(i). –  Petr Pudlák Jun 29 '13 at 13:52

1 Answer 1

The details are mentioned on the first paragraph on hackage. As pointed by @AndrewC they offer many operations efficiently example concatenating two sequences, viewing the right end of a sequence or adding elements at the end of a sequence.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.