Programming-Idioms

History of Idiom 42 > diff from v10 to v11

Edit summary for version 11 :

Version 10

2015-08-21, 08:00:27

Version 11

2015-08-21, 23:19: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. Just learned this.
Doc URL
http://dlang.org/statement.html#ContinueStatement
Origin
http://dlang.org/statement.html#ContinueStatement