Example: Concatenate lists a and b
list procedure cat(list a, list b)
{
   list t = list u = copylist(a);
   while (t.tail != nil) t = t.tail;
   t.tail = b;
   return u;
}
In an imperative language
cat(a,b)
 if b = nil then a
else cons(head(a),
cat(tail(a),b))
In a functional language
In a declarative language
cat([], Z, Z).
cat([H|T], L, [H|Z]) :- cat(T, L, Z).
31