2019-03-10

(sph vector selection)

create and analyse selections from sets: permutations, combinations, n-tuples

part of sph-lib

import name

(sph vector selection)

exports

variable: sph-vector-selection-description
procedure: vector-distinct-count a [min-width max-width] ->
vector integer integer -> integer
count all distinct sub-vectors in a vector with lengths from min-width to max-width.
distinctness is defined by elements, order and length
procedure: vector-distinct-maximum width [min-width] ->
integer integer -> integer
calculate the maximum number of possible distinct tuples in a tuple up to width, optionally ignoring widths smaller than min-width
procedure: vector-distinct-stream a [min-width max-width] ->
vector [integer integer] -> stream
return a stream of all distinct sub-vectors in a vector with lengths from min-width to max-width.
top to bottom.
distinctness is defined as with vector-distinct-count
procedure: vector-numeric-increment-be a base ->
vector integer -> vector
treat integers in a vector as digits of a number to "base" and increment it.
the least significant digit is the last element of the vector.
returns false if the maximum value has been reached
procedure: vector-numeric-increment-be! a base ->
vector integer -> true/false
like "vector-numeric-increment-be" but modifies the input vector
procedure: vector-numeric-increment-le a base ->
vector integer -> vector
treat integers in a vector as digits of a number to "base" and increment it.
the least significant digit is the first element of the vector.
return false if the maximum value has been reached
procedure: vector-numeric-increment-le! a base ->
vector integer -> true/false
like "vector-numeric-increment-le" but modifies the input vector
procedure: vector-selection set-indices set ->
vector:#(integer ...) vector -> vector
return a new vector of values at indices in set
procedure: vector-selection-maximum set-length [selection-width] ->
integer integer -> integer
calculate the maximum number of possible distinct selections from a set with length "set-length" and
optional "selection-width" which defaults to "set-length"
procedure: vector-selections set [width] ->
vector integer -> (vector ...)
return a list of all distinct selections of values from "set" with duplicate elements allowed. set can contain any datatype.
the optional parameter "width" specifies the length of selections.
for example, a width of two creates all possible two element selections of set.
the default for "width" is the length of the set
procedure: vector-selections-stream selection [width] ->
vector width -> stream
like vector-selections but returns an srfi-41-stream and calculates next results on demand