"mutate" now actually works

This commit is contained in:
FelixBrendel
2018-10-21 19:46:52 +02:00
parent ea72a6c252
commit ce28d94a9a
4 changed files with 42 additions and 35 deletions
+10 -1
View File
@@ -5,6 +5,15 @@
"Checks if the argument is nil."
(= x nil)))
(define append
(lambda (seq elem)
(if (nil? seq)
nil
(if (not (= (type (rest seq)) :pair))
;; we are on the last element
(mutate seq (pair (first seq) elem))
(append (rest seq) elem)))))
(define last
(lambda (seq)
"Returns the last element of the given sequence."
@@ -79,5 +88,5 @@ as compared to `reduce'."
(print sep))
;; TODO(Felix): later we should use `extend' here:
;; (eval (extend (quote (printf :sep sep :end end)) (rest args)))
(eval (pair printf (pair :sep (pair sep (pair :end (pair end (rest args)))))))
(eval (extend '(printf :sep sep :end end) (rest args)))
nil))))