Haskell functions to find sequences in lists.
Find a file
2026-08-30 19:41:25 +02:00
Data/List Module description. 2011-08-12 22:52:57 +02:00
.gitignore Added .gitignore. 2011-08-13 12:54:17 +02:00
data-list-sequences.cabal Prepared cabal configuration for upload to Hackage. 2011-08-13 12:53:22 +02:00
LICENSE Initial import. 2011-08-12 22:46:37 +02:00
README.md Added README.md. 2026-08-30 19:41:25 +02:00
Setup.hs Initial import. 2011-08-12 22:46:37 +02:00

Data.List.Sequences

Utilities for finding sequences within lists.

Description

Find sequences within lists.

Synopsis

  • splitSeq :: (a -> a -> Bool) -> [a] -> [[a]]
  • spanSeq :: (a -> a -> Bool) -> [a] -> ([a], [a])

Documentation

splitSeq

splitSeq :: (a -> a -> Bool) -> [a] -> [[a]]

Find sequences within a list and return them as new list of sequences. The first argument is a function that takes two subsequent elements of the given list (second argument) and returns whether the second element follows the first one in a sequence.

splitSeq ((==) . succ) [1,2,3,5,6,7]
[[1,2,3],[5,6,7]]

spanSeq

spanSeq :: (a -> a -> Bool) -> [a] -> ([a], [a])

Works pretty much like splitSeq, except that a tuple with only the sequence starting at the first element and the rest of the list is returned.

spanSeq ((==) . succ) "abcxyz123"
("abc","xyz123")