textwrite 0.7.0

TextWrite: the Fast Text scripting language (lexer, parser, interpreter, REPL).
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# Working with text: splitting, transforming, and filtering.
let sentence = "the quick brown fox jumps over the lazy dog"
let words = split(sentence, " ")

fn longest(items) {
    let best = ""
    for item in items {
        if len(item) > len(best) {
            best = item
        }
    }
    return best
}

print "word count:", len(words)
print "longest word:", longest(words)
print "shouting:", join(map(words, fn(w) { return upper(w) }), " ")
print "t-words:", filter(words, fn(w) { return starts_with(w, "t") })