Let's assume I've got two lists: ("A" "B" "C" "D")
and ("+" "-")
. I want to concatenate each element of the first list with every element of the second to get ("A+" "A-" "B+" "B-" ... )
. Is there a proper function to do that, e.g. (map-each 'concat list1 list2) => list3
?
I came to a solution using nested mapcar
calls and reduce
but I think I may be missing something since it doesn't seem to be very uncommon task.
(reduce 'append
(mapcar
(lambda (x)
(mapcar
(lambda (y)
(concat x y))
'("+" "-")))
'("A" "B" "C" "D")))