Logo

Programming-Idioms

History of Idiom 42 > diff from v8 to v9

Edit summary for version 9 by :

Version 8

2015-08-20, 23:28:46

Version 9

2015-08-20, 23:35:25

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.

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.

Imports
import std.stdio;
Imports
import std.stdio;
Code
auto a = [1,2,3,4,5];
auto b = [3,5];

void main()
{
mainloop:
	foreach(v;  a){
		foreach(w; b){
			if(v == w) continue mainloop;
		}
		writeln(v);		 
	}
}
Code
auto a = [1,2,3,4,5];
auto b = [3,5];

void main()
{
mainloop:
	foreach(v;  a){
		foreach(w; b){
			if(v == w) continue mainloop;
		}
		writeln(v);		 
	}
}
Comments bubble
I wasn't aware continue to label worked in D, but apparently so.
Comments bubble
I wasn't aware continue to label worked in D. Just learned this.
Origin
http://dlang.org/statement.html#ContinueStatement