toolshed-0.14.0.0: Utilities used by other packages.

Safe HaskellNone

ToolShed.Data.List

Contents

Description

AUTHOR
Dr. Alistair Ward
DESCRIPTION
Miscellaneous polymorphic list-operations.

Synopsis

Types

Type-synonyms

type ChunkLength = IntSource

The length of the chunks into which a list is split.

Functions

chunkSource

Arguments

:: ChunkLength 
-> [a]

The polymorphic input list to be chunked.

-> [[a]] 
  • Splits a list into length-size pieces, where (size >= 0).
  • The last chunk will be shorter, if n isn't an aliquot part of the input list-length.
  • If (size == 0), the resulting list will be an infinite sequence of null lists.
  • CAVEAT: a similar function is available in the module Data.List.Split, though this one checks for (size < 0).

exciseSource

Arguments

:: Int

The index.

-> [a]

The polymorphic input list.

-> [a]

The same list, with the indexed element removed.

Remove the single indexed element from the list.

equalityBy :: Eq b => (a -> b) -> a -> a -> BoolSource

A convenient way to compose the function-parameter required by groupBy or nubBy.

findConvergence :: Eq a => [a] -> aSource

A specific instance of findConvergenceBy.

findConvergenceBy :: (a -> a -> Bool) -> [a] -> aSource

Take the first element from the list, which compares equal according to the specified predicate, with the subsequent element.

linearise :: [(a, a)] -> [a]Source

Converts a list of Pairs, into a narrower list.

merge :: Ord a => [a] -> [a] -> [a]Source

A specific instance of mergeBy.

mergeBy :: (a -> a -> Ordering) -> [a] -> [a] -> [a]Source

  • Merge two sorted lists, according to the specified order, to product a single sorted list.
  • The merge-process is stable, in that where items from each list are equal, they remain in the original order.
  • CAVEAT: duplicates are preserved.

nub' :: Ord a => [a] -> [a]Source

  • A version of nub with better time-complexity.
  • CAVEAT: it sorts the output as a side-effect, & consequently it requires a type which implements Ord.

permutations :: [[a]] -> [[a]]Source

takeUntilSource

Arguments

:: (a -> Bool)

Predicate, used to determine the last item taken.

-> [a]

The polymorphic input list.

-> [a] 
  • Take until the specified predicate is satisfied; including the item which satisfied it.
  • NB: takeWhile (not . test) would return one fewer item.

showListWithSource

Arguments

:: (Show token, Show element) 
=> (token, token, token)

(Start-delimiter, separator, end-delimiter)

-> [element]

The polymorphic list to show.

-> ShowS 

Show a list, delimited by the specified tokens.