Module "Combinatorial.curry"

A collection of common non-deterministic and/or combinatorial operations. Many operations are intended to operate on sets. The representation of these sets is not hidden; rather sets are represented as lists. Ideally these lists contains no duplicate elements and the order of their elements cannot be observed. In practice, these conditions are not enforced.

Author: Sergio Antoy

Version: August 2004


 Exported names:

Functions:
partition | permute | sizedSubset | splitSet | subset


 Summary of exported functions:

permute  :: [a] -> [a]  deterministic flexible
          Compute any permutation of a list.
subset  :: [a] -> [a]  non-deterministic flexible
          Compute any sublist of a list.
splitSet  :: [a] -> ([a],[a])  deterministic flexible
          Split a list into any two sublists.
sizedSubset  :: Int -> [a] -> [a]  deterministic rigid
          Compute any sublist of fixed length of a list.
partition  :: [a] -> [[a]]  deterministic flexible
          Compute any partition of a list.

 Imported modules:

Prelude

 Exported datatypes:


 Exported functions:

permute :: [a] -> [a]  deterministic flexible

Compute any permutation of a list. For example, [1,2,3,4] may give [1,3,4,2].

Example call:  (permute l)

Parameters:
l - The list.
Returns:
A permutation of the argument.
Further infos:

subset :: [a] -> [a]  non-deterministic flexible

Compute any sublist of a list. The sublist contains some of the elements of the list in the same order. For example, [1,2,3,4] may give [1,3], and [1,2,3] gives [1,2,3], [1,2], [1,3], [1], [2,3], [2], [3], or [].

Example call:  (subset l)

Parameters:
l - The list.
Returns:
A sublist of the argument.
Further infos:

splitSet :: [a] -> ([a],[a])  deterministic flexible

Split a list into any two sublists. For example, [1,2,3,4] may give ([1,3,4],[2]).

Example call:  (splitSet l)

Parameters:
l - The list.
Returns:
A pair consisting of two complementary sublists of the argument.
Further infos:

sizedSubset :: Int -> [a] -> [a]  deterministic rigid

Compute any sublist of fixed length of a list. Similar to subset, but the length of the result is fixed.

Example call:  (sizedSubset c l)

Parameters:
c - The length of the output sublist.
l - The input list.
Returns:
A sublist of l of length c.
Further infos:

partition :: [a] -> [[a]]  deterministic flexible

Compute any partition of a list. The output is a list of non-empty lists such that their concatenation is a permutation of the input list. No guarantee is made on the order of the arguments in the output. For example, [1,2,3,4] may give [[4],[2,3],[1]], and [1,2,3] gives [[1,2,3]], [[2,3],[1]], [[1,3],[2]], [[3],[1,2]], or [[3],[2],[1]].

Example call:  (partition l)

Parameters:
l - The input list.
Returns:
A partition of l represented as a list of lists.
Further infos:


Generated by CurryDoc (Version 0.4.1 of June 7, 2007) at Aug 28 15:27:31 2008