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: |
|
||
|
||
|
||
|
||
|
| Imported modules: |
| Exported datatypes: |
| Exported functions: |
:: [a] -> [a]
Compute any permutation of a list.
For example, [1,2,3,4] may give [1,3,4,2].
Example call: (permute l)
l
- The list.
:: [a] -> [a]
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)
l
- The list.
:: [a] -> ([a],[a])
Split a list into any two sublists.
For example, [1,2,3,4] may give ([1,3,4],[2]).
Example call: (splitSet l)
l
- The list.
:: Int -> [a] -> [a]
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)
c
- The length of the output sublist.
l
- The input list.
l of length c.
:: [a] -> [[a]]
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)
l
- The input list.
l represented as a list of lists.