As a final addition to Data.Sequence, I&#39;ve <a href="http://hackage.haskell.org/trac/ghc/attachment/ticket/3271/new-methods-for-data_sequence.5.dpatch">added</a> the following methods.  Possibly debatable design decisions are highlighted.<br>

<ul><li>mapWithIndex :: (Int -&gt; a -&gt; b) -&gt; Seq a -&gt; Seq b.  (This is based on mapAccumL, which is slightly suboptimal [as the full mapping must be done before the last element can be examined], but acceptable given the tiny code investment.)</li>

<li>elemIndex, elemIndices, findIndex, findIndices, all as in Data.List.</li><li>elemLastIndex, findLastIndex, elemIndicesDesc, findIndicesDesc, all working from right-to-left but otherwise analogous.  *<b>Note:*</b> findIndicesDesc and elemIndicesDesc return lists, not Sequences, so as to permit maximum laziness.  Moreover, both of those methods fuse well.<br>

</li><li>takeWhileEnd, dropWhileEnd, spanEnd, breakEnd, all of which work from right-to-left but otherwise perform as their Data.List analogues.  <b>*Note:*</b> spanEnd p xs, in particular, returns <i>first</i> the longest <i>suffix</i> of xs of elements satisfying p, and then the remaining prefix.<br>

</li></ul>All but mapWithIndex take O(i) time, where i is the appropriate breakpoint -- that is, they don&#39;t necessarily search the entire sequence.  (Each of the xxxEnd methods take O(n-i).)<br><br>None of these methods are particularly code-intensive, save for some rewrite-rules-based code that lets most of those methods be defined in terms of findIndex, without any performance loss.  (In the absence of rewrite rules, the additional overhead  is small.)<br>

<br clear="all">Louis Wasserman<br><a href="mailto:wasserman.louis@gmail.com">wasserman.louis@gmail.com</a><br>