aboutsummaryrefslogtreecommitdiff
path: root/p99/p17.neb
blob: d586e87b16a3fddc2dcbc51c0738aad03a0e4f0c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
; P17 Split a list into two parts; the length of the first part is given.
; Do not use any predefined functions.

(def a (list "a" "b" "c" "d" "e" "f" "g" "h" "i" "k"))

(func spl (lst idx)
    (spl lst idx (list)))

(func spl (lst idx acc)
    (if (eq? idx 0)
        (list acc lst)
        (spl (rest lst) (-- idx) (append acc (first lst)))))

(func -- (num) (- num 1))

(print (->string a))
(print (->string (spl a 3)))