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