3

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

2
  • 8
    They're more efficient for many operations, such as concatenation, especially on the right. Commented Jun 29, 2013 at 13:34
  • 12
    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). Commented Jun 29, 2013 at 13:52

1 Answer 1

14

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.