; P18 Extract a slice from a list. ; Given two indices, I and K, the slice is the list containing the elements between the ; I'th and K'th element of the original list (both limits included). Start counting the elements with 1. (def a (list "a" "b" "c" "d" "e" "f" "g" "h" "i" "k")) (func my-slice (lst idx1 idx2) (my-slice lst idx1 idx2 (list))) (func my-slice (lst :nil idx1 idx2 acc) acc) (func my-slice (lst :{:any} idx1 idx2 acc) (my-slice (rest lst) (-- idx1) (-- idx2) (if (or (> idx1 1) (< idx2 1)) acc (append acc (first lst))))) (func -- (num) (- num 1)) (print (->string a)) (print (->string (my-slice a 3 7)))