aboutsummaryrefslogtreecommitdiff
path: root/core.neb
blob: 308d9aa2d4ebf533743772ede402b7b02376f9ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
; math
(func ++ (num) (+ num 1))
(func -- (num) (- num 1))

; strings
(func join (lst joiner)
    ; TODO this doesn't handle empty lists
    (concat
        (reduce
            (lambda (acc x)
                (concat acc x joiner))
            (most lst)
            "")
        (last lst)))

(func strip (str)
    ; TODO need escape codes
    (def whitespace (list " " "	" "
"))
    (branch
        ((in? (first str) whitespace) (strip (rest str)))
        ((in? (last str) whitespace) (strip (most str)))
        (#true str)))

; lists
(func slice (lst idx)
    ; TODO doesn't handle lengths
    (if (eq? 1 idx)
        lst
        (slice (rest lst) (- idx 1))))