Consider the following code snippet:
-- list_1 = [1, 2, 3] -- list_2 = [4, 5, 6] final_list = list_1 ++ list_2 result = map (+1) final_list
Is the time spent by it proportional just to the length of
final_list, and the price of list concatenation is not paid?
My idea is that concatenation is done lazily; to quote the source of GHC Base.hs,
(++) :: [a] -> [a] -> [a] (++)  ys = ys (++) (x:xs) ys = x : xs ++ ys
map constantly chips away the head of the list, I suppose that the concatenation as done by the recursive call in the last line is always done in lockstep with the
map execution, so
list_1 is effectively scanned only once.
Is this correct?