You need to apply car
to every element (sublist) of the main list, using map
:
(define (concatenate lst)
(map car lst))
(concatenate '(("one" "two") ("three" "four") ("five" "six")))
=> '("one" "three" "five")
To print these values each on its own line, use for-each
:
(for-each displayln (concatenate '(("one" "two") ("three" "four") ("five" "six"))))
=>
one
three
five
You could also use map
instead of for-each
, but then you'd get
one
three
five
'(#<void> #<void> #<void>)
The trailing '(#<void> #<void> #<void>)
is the result of applying displayln
to each value (displayln
always returns void). So use map
if you care about the result, for-each
if you don't.