diff options
Diffstat (limited to 'p99/p16.neb')
| -rw-r--r-- | p99/p16.neb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/p99/p16.neb b/p99/p16.neb new file mode 100644 index 0000000..e8fc459 --- /dev/null +++ b/p99/p16.neb @@ -0,0 +1,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))) |
