This language bar is your friend. Select your favorite languages!
Select your favorite languages :
- Or search :
int gb = 0;
foreach (int v in a)
{
foreach (int w in b)
{
gb = w;
if (w == v)
break;
}
if (gb == v)
continue;
System.Console.WriteLine(v);
}
This borrows from the Pascal implementation.
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);
}
}
main() {
var a = [1, 2, 3];
var b = [2, 3];
outer: for (var v in a) {
for (var w in b) {
if (w == v) continue outer;
}
print(v);
}
}
mainloop:
for _, v := range a {
for _, w := range b {
if v == w {
continue mainloop
}
}
fmt.Println(v)
}
mainloop is a label used to refer to the outer loop.
sequence_ [ print v | v <- a, [ u | u <- b, u == v] == [] ]
a _\\ b abbreviates this task if you are not required to write your own printing iterations
Our outer loop continues to the next element whenever the inner list equality test breaks the inner iteration lazily after the first of any [u|u==w] found growing too large to equal [].
Our outer loop continues to the next element whenever the inner list equality test breaks the inner iteration lazily after the first of any [u|u==w] found growing too large to equal [].
mainloop: for(int v:a){
for(int w:b){
if(v==w)
continue mainloop;
}
System.out.println(v);
}
mainloop is a label used to refer to the outer loop.
$array_1 = [1,2,3,4,5];
$array_2 = [3,4];
foreach ($array_1 as $a) {
foreach ($array_2 as $b) {
if ($b == $a) {
continue 2;
}
}
echo $a
}
The number next to the continue statement determines how many loops "up" it should skip. continue 1 is the same as continue with no numerical argument passed, and will skip to the next iteration of the current loop.
for v in a:
keep = True
for w in b:
if w == v:
keep = False
break
if keep:
print(v)
Using a boolean variable