Skip to content

stdlib_lang

Neil Tallim edited this page Jul 14, 2015 · 3 revisions

Introduction

The lang namespace is home to language functions that do not belong to a specific domain, like math.

Provides

Functions

build_range(stop, start=0, step=1)

Provides an iterator from start to stop, in increments of range, intended primarily for use in forloops that need to run a fixed number of times.

If you wish to generate a sequence of integers, this function's output may be passed as items-input to the Sequence type.

zip(sequences, pad=False, pad_values=None)

Builds a sequence of subsequences containing as many elements as the number of sequences initially provided, to either the length of the shortest sequence (default) or the longest, if pad is True.

If pad is True, pad_values must be a sequence with as many items as the number of sequences provided; its items will be placed on the end of the sequentially corresponding sequence to make all sequences the same length.

Example:

x = lang.zip(
 sequences=[
  [1, 2, 3, 4],
  ['a', 'b', 'c'],
  [5, 6]
 ],
 pad=True,
 pad_values=[0, 'z', None]
);

Post-execution, x will have the following value:

[
 [1, 'a', 5],
 [2, 'b', 6],
 [3, 'c', None],
 [4, 'z', None]
]
Clone this wiki locally