Module: List

This module provides a simple singly linked list.

Note

This module is expected to change in the future.

record list

A singly linked list.

Note

destroy must be called to reclaim any memory used by the list.

type eltType

The type of the data stored in every node.

var length: int

The number of nodes in the list.

iter these()

Iterate over the list, yielding each element.

Yield type:eltType
proc append(e: eltType)

Append e to the list.

proc append(e: eltType, es: eltType ...?k)

Append all of the supplied arguments to the list.

proc prepend(e: eltType)

Prepend e to the list.

proc concat(l: list(eltType))

Append all the elements in l to the end of the list.

proc remove(x: eltType)

Remove the first encountered instance of x from the list.

proc destroy()

Delete every node in the list.

proc makeList(x ...?k)

Construct a new list containing all of the supplied arguments.

Arguments:x : T – Every argument must be of type T.
Return type:list(T)