erg_compiler 0.6.53

Centimetre: the Erg compiler
Documentation
.List: ClassType
.List.
    '''
    Concatenates two arrays. Same as `self + other`.
    '''
    '''erg
    assert [1, 2].concat([3, 4]) == [1, 2, 3, 4]
    '''
    concat: |T: Type, M: Nat, N: Nat|(self: List(T, M), other: List(T, N)) -> List(T, M + N)
    '''
    Returns the number of elements in the array.
    '''
    '''erg
    assert [1, 2, 3, 1, 2].count(1) == 2
    assert ["a", "b", "c"].count("a") == 1
    '''
    count: |T: Type, N: Nat|(self: List(T, N), x: T) -> Nat
    '''
    Remove array duplicates.

    If `same_bucket` is not provided, it is used for the equality comparison.
    If lhs and rhs are considered to be equal, __lhs__ will be removed.
    '''
    '''erg
    assert [1, 1, 2].dedup() == [1, 2]
    assert [0.0, 0.1, 10.0, 20.0, 20.1].dedup((lhs, rhs) -> abs(lhs - rhs) < 1.0) == [0.1, 10.0, 20.1]
    '''
    dedup: |T: Type|(self: List(T, _), same_bucket := (T, T) -> Bool) -> List(T, _)
    '''
    Create two arrays according to the `predicate` function.

    What is returned is a tuple of two arrays, the first containing the elements judged to be `True` and the second containing the elements `False`.
    '''
    '''erg
    assert [-2, -1, 0, 1, 2].partition(x -> x >= 0) == ([0, 1, 2], [-2, -1])
    '''
    partition: |T: Type|(self: List(T, _), predicate: T -> Bool) -> (List(T, _), List(T, _))
    '''
    Returns the summation of all elements in the array.
    '''
    '''erg
    assert [1, 2, 3].sum() == 6
    '''
    sum: |T: Type|(self: List(T, _), start := T) -> T
    '''
    Returns the product of all elements in the array.
    '''
    '''erg
    assert [1, 2, 3].product() == 6
    '''
    prod: |T: Type|(self: List(T, _), start := T) -> T
    '''
    Returns the reversed array.
    '''
    '''erg
    assert [1, 2, 3].reversed() == [3, 2, 1]
    '''
    reversed: |T: Type, N: Nat|(self: List(T, N)) -> List(T, N)
    '''
    Returns the array with the first `nth` elements removed.
    '''
    '''erg
    assert [1, 2, 3, 4, 5].from(2) == [3, 4, 5]
    '''
    from: |T: Type|(self: List(T, _), nth: Nat) -> List(T, _)
    '''
    Return the index of the first occurrence of `x` in the array.
    '''
    '''erg
    assert [1, 2, 3].index(2) == 1
    '''
    index: |T: Type|(self: List(T, _), x: T) -> Nat