Skip to content

Functions

Import use statements are necessary to bring these functions into scope, e.g.: use stdlib.v1.collection.take.

Collection

range

<function> Creates a new range as a list of numbers.

Arguments

start - Number - inclusive start of the range

end - Number - inclusive end of the range

step - Number - the increment step of each element in the range

Returns

List<Number> - a list containing all elements in the range

Usage
var x: List<Number> = range(start = -4, end = 4, step = 2); // listOf(-4, -2, 0, 2, 4)

Text

trim

<function> Trims a Text at both start and end.

Receiver

Text

Returns

Text - the trimmed text

Usage
var x: Text = " one ".trim(); // "one"

equals

<function> Compares whether two Texts are equal.

Receiver

Text

Arguments

other - Text - the other Text to compare against

ignoreCase - Boolean - whether the comparison should be case sensitive

Returns

Boolean - true if both Text are equal, false otherwise

Usage
var x: Boolean = "one".equals("One", ignoreCase = true); // true
var y: Boolean = "one".equals("One", ignoreCase = false); // false

slice

<function> Slices a Text from a starting index to an inclusive end index.

Receiver

Text

Arguments

indexStart - Number - the inclusive start position in the Text from which to start slicing

indexEnd - Number - the exclusive end position in the Text from which to end slicing

Returns

Text - a sliced portion of the original Text

Usage
var x: Text = "one".slice(0, 2); // "on"

Math

product

<function> Multiplies every element of the Collection together. One (1) is always returned for the product of an empty Collection. A Collection containing a zero (0) value will always return 0.

Receiver

Collection<Number>

Returns

Number - the result of multiplying each element of the Collection with each other

Usage
var x: Number = listOf(1, 2, 3).product(); // 6
var y: Number = setOf(1, 2, 3).product(); // 6

toThePowerOf

<function> Raises a Number to the given exponent using double-precision arithmetic (IEEE 754 standard), which may affect the precision of the result.

Receiver

Number

Arguments

exponent - Number - the exponent to raise the Number

Returns

Optional<Number> - An Optional of type Some of the Number raised to the exponent if successful, otherwise an Optional of type None

Usage
var x: Optional<Number> = 2.toThePowerOf(4); // 16

log

<function> Returns the logarithm with the given base using double-precision arithmetic (IEEE 754 standard), which may affect the precision of the result.

Receiver

Number

Arguments

base - Number - the base of the logarithm

Returns

Optional<Number> - An Optional of type Some of the Number raised to the exponent if successful, otherwise an Optional of type None

Usage
var x: Optional<Number> = 10.log(10); // 1

minBetween

<function> Returns the minimum between two (2) Number.

Arguments

a - Number - the first Number

b - Number - the second Number

Returns

Number - the minimum between Number a and Number b

Usage
var x: Number = minBetween(1, 2); // 1

maxBetween

<function> Returns the maximum between two (2) Number.

Arguments

a - Number - the first Number

b - Number - the second Number

Returns

Number - the maximum between Number a and Number b

Usage
var x: Number = maxBetween(1, 2); // 2

min

<function> Returns the minimum of a Collection of Numbers.

Receiver

Collection<Number>

Returns

Optional<Number> - An Optional of type Some of the minimum, otherwise an Optional of type None if the Collection is empty.

Usage
var x: Optional<Number> = listOf(1, 2, 3).min(); // Some(1)
var y: Optional<Number> = setOf(1, 2, 3).min(); // Some(1)

max

<function> Returns the maximum of a Collection of Numbers.

Receiver

Collection<Number>

Returns

Optional<Number> - An Optional of type Some of the maximum, otherwise an Optional of type None if the Collection is empty.

Usage
var x: Optional<Number> = listOf(1, 2, 3).max(); // Some(3)
var y: Optional<Number> = setOf(1, 2, 3).max(); // Some(3)