From 7b7bf727da3250907284368b98b0083a4b4e2386 Mon Sep 17 00:00:00 2001 From: mryouse Date: Sat, 3 Jun 2023 20:22:18 +0000 Subject: initial commit --- p99/p19.neb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 p99/p19.neb (limited to 'p99/p19.neb') diff --git a/p99/p19.neb b/p99/p19.neb new file mode 100644 index 0000000..09ff324 --- /dev/null +++ b/p99/p19.neb @@ -0,0 +1,15 @@ +; P19 Rotate a list N places to the left. + +(def a (list "a" "b" "c" "d" "e" "f" "g" "h")) + +(func rotate (lst cnt) + (branch + ((eq? 0 cnt) lst) + ((> cnt 0) + (rotate (append (rest lst) (first lst)) (- cnt 1))) + ((< cnt 0) + (rotate (prepend (most lst) (last lst)) (+ cnt 1))))) + +(print (->string a)) +(print (->string (rotate a 3))) +(print (->string (rotate a (- 2)))) -- cgit v1.2.3