2017-08-27

(sph vector selection)

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

import name

(sph vector selection)

exports

sph-vector-selection-description

variable

vector-distinct-count

procedure

signature

a [min-width max-width] ->

vector integer integer -> integer

description

count all distinct sub-vectors in a vector with lengths from min-width to max-width.

distinctness is defined by elements, order and length

vector-distinct-maximum

procedure

signature

width [min-width] ->

integer integer -> integer

description

calculate the maximum number of possible distinct tuples in a tuple up to width, optionally ignoring widths smaller than min-width

vector-distinct-stream

procedure

signature

a [min-width max-width] ->

vector [integer integer] -> stream

description

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

vector-numeric-increment-be

procedure

signature

a base ->

vector integer -> vector

description

treat a vector of integers as a whole like one number to "base" in big endian and increment it

returns false if the maximum value has been reached

vector-numeric-increment-be!

procedure

signature

a base ->

vector integer -> true/false

description

like "vector-numeric-increment-be" but modifies the input vector

vector-numeric-increment-le

procedure

signature

a base ->

vector integer -> vector

description

treat a vector of integers as a whole like one number to "base" in little endian and increment it.

returns false if the maximum value has been reached

vector-numeric-increment-le!

procedure

signature

a base ->

vector integer -> true/false

description

like "vector-numeric-increment-le" but modifies the input vector

vector-selection

procedure

signature

set-indices set ->

vector:#(integer ...) vector -> vector

description

return a new vector of values at indices in set

vector-selection-maximum

procedure

signature

set-length [selection-width] ->

integer integer -> integer

description

calculate the maximum number of possible distinct selections from a set with length "set-length" and

optional "selection-width" which defaults to "set-length"

vector-selections

procedure

signature

set [width] ->

vector integer -> (vector ...)

description

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

vector-selections-stream

procedure

signature

selection [width] ->

vector width -> stream

description

like vector-selections but returns an srfi-41-stream and calculates next results on demand


tags: programming guile documentation library scheme sph-lib q1 computer highlight combination permutation sph-vector-selection