Logo

Programming-Idioms

History of Idiom 218 > diff from v4 to v5

Edit summary for version 5 by Bart:
New Pascal implementation by user [Bart]

Version 4

2020-01-09, 16:33:14

Version 5

2020-01-10, 23:13:14

Idiom #218 List intersection

Create list c containing all unique elements that are contained in both lists a and b.
c should not contain any duplicates, even if a and b do.
The order of c doesn't matter.

Idiom #218 List intersection

Create list c containing all unique elements that are contained in both lists a and b.
c should not contain any duplicates, even if a and b do.
The order of c doesn't matter.

Extra Keywords
intersect and conjunction
Extra Keywords
intersect and conjunction
Imports
Classes
Code
for elem in a do
  if (b.indexof(elem) >= 0) and (c.indexof(elem) = -1) then
    c.add(elem);