Skip to content

List

A list of elements.

Type parameters:

Name Upper Bound Description Default
E Any? - -

Examples:

pipeline example {
    val list = [1, 2, 3];
}
Stub code in coreClasses.sdsstub

class List<out E> {

    /**
     * Join the elements of the list into a string using the separator.
     *
     * @example
     * pipeline example {
     *     val string = [1, 2, 3].join(); // "1, 2, 3"
     * }
     *
     * @example
     * pipeline example {
     *     val string = [1, 2, 3].join(separator = "-"); // "1-2-3"
     * }
     */
    @Pure
    @PythonMacro("$separator.join($this)")
    fun join(separator: String = ", ") -> string: String

    /**
     * Return the slice of the list starting at the start index up to but excluding the end index.
     *
     * @param start The start index (inclusive).
     * @param end The end index (exclusive). Negative indices count from the end of the list.
     *
     * @example
     * pipeline example {
     *     val slice = [1, 2, 3].slice(start = 1, end = 3); // [2, 3]
     * }
     */
    @Pure
    @PythonMacro("$this[$start:$end]")
    fun slice(start: Int = 0, end: Int = this.size()) -> slice: List<E>

    /**
     * Return the number of elements in the list.
     *
     * @example
     * pipeline example {
     *     val size = [1, 2, 3].size(); // 3
     * }
     */
    @Pure
    @PythonMacro("len($this)")
    fun size() -> size: Int
}

join

Join the elements of the list into a string using the separator.

Parameters:

Name Type Description Default
separator String - ", "

Results:

Name Type Description
string String -

Examples:

pipeline example {
    val string = [1, 2, 3].join(); // "1, 2, 3"
}
pipeline example {
    val string = [1, 2, 3].join(separator = "-"); // "1-2-3"
}

Stub code in coreClasses.sdsstub

@Pure
@PythonMacro("$separator.join($this)")
fun join(separator: String = ", ") -> string: String

size

Return the number of elements in the list.

Results:

Name Type Description
size Int -

Examples:

pipeline example {
    val size = [1, 2, 3].size(); // 3
}
Stub code in coreClasses.sdsstub

@Pure
@PythonMacro("len($this)")
fun size() -> size: Int

slice

Return the slice of the list starting at the start index up to but excluding the end index.

Parameters:

Name Type Description Default
start Int The start index (inclusive). 0
end Int The end index (exclusive). Negative indices count from the end of the list. this.size()

Results:

Name Type Description
slice List<E> -

Examples:

pipeline example {
    val slice = [1, 2, 3].slice(start = 1, end = 3); // [2, 3]
}
Stub code in coreClasses.sdsstub

@Pure
@PythonMacro("$this[$start:$end]")
fun slice(start: Int = 0, end: Int = this.size()) -> slice: List<E>