blob: e8fc459fd0e2181dac7a98bffdfdec01c33f1e04 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
; P16 Drop every N'th element from a list.
(def a (list "a" "b" "c" "d" "e" "f" "g" "h" "i" "k"))
(func drop-n (lst n)
(drop-n lst n (list) n))
(func drop-n (lst :nil n acc idx)
acc)
(func drop-n (lst :{:any} n acc idx)
(if (eq? 1 idx)
(drop-n (rest lst) n acc n) ; reset n, don't add to acc
(drop-n (rest lst) n (append acc (first lst)) (-- idx))))
(func -- (num) (- num 1))
(print (->string a))
(print (->string (drop-n a 3)))
|