====== Merge ====== A merge is an operation used when describing the [[structure|structure]] of a [[procedure|procedure]]. It builds a single hybrid structure out of two or more structures, so that the procedure can traverse all the trees at once. The easiest way to do this is to merge the [[naive_procedure|naive procedures]] written for each structure. For example, the input is a list of orders sorted by customer, and the output is a report with one line per customer showing their total. In the input tree, the list is a [[sequence|sequence]] of customers, each with a sequence of orders; in the output tree, the report is a sequence of lines. Each customer corresponds to exactly one line, so the trees fit together: the merged procedure goes through the customers one by one, adds up each customer’s orders and writes one line.