Set both and equal to list concatenation, with . Associativity gives xs ++ (ys ++ zs) = (xs ++ ys) ++ zs, which is equation (1). The two identity laws give xs ++ [] = [] ++ xs, which is equation (2). Part (b) therefore yields
concat :: [[a]] -> [a]
concat = foldl (++) []
Thus on finite lists. The argument order is unchanged: the accumulator is the already concatenated prefix, and the next inner list is appended to its right. This preserves the order but repeatedly copies that prefix.

Articles by others on the same topic (0)

There are currently no matching articles.