;; P21 (*) Insert an element at a given position into a list. ;; Example: ;; * (insert-at 'alfa '(a b c d) 2) ;; (A ALFA B C D) (define (insert-at elm lst pos) (let loop ((lst lst) (pos pos) (acc '())) (if (or (= pos 1) (null? lst)) (append (reverse acc) (cons elm lst)) (loop (cdr lst) (- pos 1) (cons (car lst) acc)))))