Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • Pascal

Idiom #166 Concatenate two lists

Create the list ab containing all the elements of the list a, followed by all the elements of the list b.

uses classes;
var
  a,b,ab: TList;

...
  ab := TList.Create;
  ab.Assign(a);
  ab.AddList(b);
...

Since ab is empty after creation we can use assign to copy the items from a. It's a bit faster than AddList().
(def ab (concat a b))

New implementation...