# Eymenium String module

blueprint String:
    exp reverse(s):
        out = ""
        i = sizeof(s) - 1
        spin i >= 0:
            out = out + s[i]
            i -= 1
        back out

    exp chars(s):
        result = []
        loop ch within s:
            append(result, ch)
        back result

    exp words(s):
        back splitstr(s, " ")

    exp join(separator, parts):
        back joinstr(separator, parts)

    exp count(s, needle):
        chk needle == "":
            back 0
        back sizeof(splitstr(s, needle)) - 1

    exp replace(s, old, new):
        chk old == "":
            back s
        back joinstr(new, splitstr(s, old))

    exp repeat(s, count):
        result = ""
        i = 0
        spin i < count:
            result = result + s
            i += 1
        back result

    exp empty(s):
        back sizeof(s) == 0
