Append a list to a sequence of lists

clojure

Solution

There may be a better solution, but here's one way:

user=> s
((1 2) (3 4) (5 6))
user=> s2
(7 8)
user=> (concat s (cons s2 '()))
((1 2) (3 4) (5 6) (7 8))

Problem

I have a sequence of lists: ``` (def s '((1 2) (3 4) (5 6))) ``` And I want to append another list to the tail of this sequence, i.e. ``` (concat-list s '(7 8)) => '((1 2) (3 4) (5 6) (7 8)) ``` Various approaches that (obviously) don't work: ``` (cons '((1 2)) '(3 4)) => (((1 2)) 3 4) (conj '(3 4) '((1 2))) => (((1 2)) 3 4) (concat '((1 2)) '(3 4)) => ((1 2) 3 4) ;; close, but wrong order... (conj '((1 2)) '(3 4)) => ((3 4) (1 2)) ;; Note: vectors work - do I really have to convert entire ;; structure from lists to vectors and back again? (conj [[1 2]] [3 4]) => [[1 2] [3 4]] ``` What are some possible implementations of `concat-list`, or does there exist library function that does this?

Original source