Programming-Idioms

History of Idiom 42 > diff from v33 to v34

Edit summary for version 34 :
New Csharp implementation by user [bigwavedave]

Version 33

2019-09-27, 13:43:17

Version 34

2019-10-04, 23:03:04

Idiom #42 Continue outer loop

Print each item v of list a which in not contained in list b.
For this, write an outer loop to iterate on a and an inner loop to iterate on b.

Illustration

Idiom #42 Continue outer loop

Print each item v of list a which in not contained in list b.
For this, write an outer loop to iterate on a and an inner loop to iterate on b.

Illustration
Code
int[] alist = {1,2,3,4,5};
int[] blist = {3,4};
int gb = 0;
foreach (int a in alist)
{
  foreach (int b in blist)
  {
    gb = b;
    if (b == a)
      break;
  }
  if (gb == a)
    continue;
  System.Console.WriteLine(a);
}
Comments bubble
This borrows from the Pascal implementation.