Data and Math

vitertools

More ways to step through a sequence, for what vseq leaves out.

Released v1.0.0 · 2026-09-28
Import
use "stdlib/itertools.ven"

Iterator style operations not already covered by the standard library's own sequence helpers, such as chaining several lists together or grouping consecutive equal items, built on Venutian's own core builtins. It fills the specific gaps left by the existing sequence package rather than duplicating what that package already covers.

vitertools.ven
print islice([10, 20, 30, 40, 50], 1, 4, 1)
Reference (15 functions)

API reference

islice(items, start, stop_index, step)

Slices items from start to stop_index by step.

islice([10, 20, 30, 40, 50], 1, 4, 1)
:: gives [20, 30, 40]

zip_longest(a, b, fillvalue)

Pairs a and b element by element out to the longer of the two.

zip_longest([1, 2, 3], [10, 20], 0)
:: gives [(1, 10), (2, 20), (3, 0)]

groupby_consecutive(items, key_fn)

Groups items into consecutive runs that share the same key.

use "stdlib/func.ven"
groupby_consecutive([1, 1, 2, 2, 1], identity)
:: gives [(1, [1, 1]), (2, [2, 2]), (1, [1])]

combinations(items, r)

Every r-length combination of items, chosen without replacement.

combinations([1, 2, 3], 2)
:: gives [[1, 2], [1, 3], [2, 3]]

permutations(items, r)

Every r-length ordered arrangement of items, chosen without replacement.

permutations([1, 2], 2)
:: gives [[1, 2], [2, 1]]

product(lists)

The Cartesian product of lists, one element from each input list.

product([[1, 2], [3, 4]])
:: gives [[1, 3], [1, 4], [2, 3], [2, 4]]

combinations_with_replacement(items, r)

Every r-length combination of items, chosen WITH replacement.

combinations_with_replacement([1, 2], 2)
:: gives [[1, 1], [1, 2], [2, 2]]

takewhile(items, pred_fn)

Takes elements from the front of items while pred_fn holds.

use "stdlib/func.ven"
takewhile([1, 2, 3, 1], make(x) give x < 3)
:: gives [1, 2]

dropwhile(items, pred_fn)

Drops elements from the front of items while pred_fn holds.

use "stdlib/func.ven"
dropwhile([1, 2, 3, 1], make(x) give x < 3)
:: gives [3, 1]

compress(items, selectors)

Keeps each element of items whose matching selectors entry is truthy.

compress([10, 20, 30, 40], [yes, no, yes, no])
:: gives [10, 30]

filterfalse(items, pred_fn)

Keeps every element of items for which pred_fn is FALSEY.

use "stdlib/func.ven"
filterfalse([1, 2, 3, 4], make(x) give x % 2 == 0)
:: gives [1, 3]

starmap2(pairs, fn)

use "stdlib/op.ven"
starmap2([(1, 2), (3, 4)], op_add)
:: gives [3, 7]

repeat_n(item, n)

item, repeated n times.

repeat_n("x", 3)
:: gives ["x", "x", "x"]

cycle_n(items, n)

items, repeated end-to-end until n total elements are produced.

cycle_n([1, 2, 3], 7)
:: gives [1, 2, 3, 1, 2, 3, 1]

count_n(start, step, n)

n values counting up from start by step.

count_n(10, 5, 4)
:: gives [10, 15, 20, 25]

Get notified when vitertools changes

Get notified about

New versions and security advisories.

New and updated packages, once a day.

News on the math model built in Venutian.