From 7b7bf727da3250907284368b98b0083a4b4e2386 Mon Sep 17 00:00:00 2001 From: mryouse Date: Sat, 3 Jun 2023 20:22:18 +0000 Subject: initial commit --- p99/p16.neb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 p99/p16.neb (limited to 'p99/p16.neb') 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))) -- cgit v1.2.3