# Eymenium List module

blueprint List:
    exp contains(items, value):
        loop item within items:
            chk item == value:
                back yes
        back no

    exp index_of(items, value):
        i = 0
        loop item within items:
            chk item == value:
                back i
            i += 1
        back -1

    exp reverse(items):
        result = []
        i = sizeof(items) - 1
        spin i >= 0:
            append(result, items[i])
            i -= 1
        back result

    exp sum(items):
        total = 0
        loop item within items:
            total += item
        back total

    exp min(items):
        chk sizeof(items) == 0:
            throw "list.min: empty list"
        result = items[0]
        i = 1
        spin i < sizeof(items):
            chk items[i] < result:
                result = items[i]
            i += 1
        back result

    exp max(items):
        chk sizeof(items) == 0:
            throw "list.max: empty list"
        result = items[0]
        i = 1
        spin i < sizeof(items):
            chk items[i] > result:
                result = items[i]
            i += 1
        back result

    exp copy(items):
        result = []
        loop item within items:
            append(result, item)
        back result
