Instruction stringlengths 45 106 | input_code stringlengths 1 13.7k | output_code stringlengths 1 13.7k |
|---|---|---|
Rewrite the snippet below in Python so it works the same as the original Nim code. | block outer:
for i in 0..1000:
for j in 0..1000:
if i + j == 3:
break outer
|
from goto import goto, label
label .start
for i in range(1, 4):
print i
if i == 2:
try:
output = message
except NameError:
print "Oops - forgot to define 'message'! Start again."
message = "Hello world"
goto .start
print output, "\n"
|
Change the programming language of this snippet from Nim to VB without modifying what it does. | block outer:
for i in 0..1000:
for j in 0..1000:
if i + j == 3:
break outer
| Public Sub jump()
Debug.Print "VBA only allows"
GoTo 1
Debug.Print "no global jumps"
1:
Debug.Print "jumps in procedures with GoTo"
Debug.Print "However,"
On 2 GoSub one, two
Debug.Print "named in the list after
Debug.Print "and execution will continue on the next line"
On 1 GoTo one, two
Debug.Print "For On Error, see Exceptions"
one:
Debug.Print "On <n> GoTo let you jump to the n-th label"
Debug.Print "and won
Exit Sub
two:
Debug.Print "On <n> GoSub let you jump to the n-th label": Return
End Sub
|
Port the following code from Nim to VB with equivalent syntax and logic. | block outer:
for i in 0..1000:
for j in 0..1000:
if i + j == 3:
break outer
| Public Sub jump()
Debug.Print "VBA only allows"
GoTo 1
Debug.Print "no global jumps"
1:
Debug.Print "jumps in procedures with GoTo"
Debug.Print "However,"
On 2 GoSub one, two
Debug.Print "named in the list after
Debug.Print "and execution will continue on the next line"
On 1 GoTo one, two
Debug.Print "For On Error, see Exceptions"
one:
Debug.Print "On <n> GoTo let you jump to the n-th label"
Debug.Print "and won
Exit Sub
two:
Debug.Print "On <n> GoSub let you jump to the n-th label": Return
End Sub
|
Convert this Nim block to Go, preserving its control flow and logic. | block outer:
for i in 0..1000:
for j in 0..1000:
if i + j == 3:
break outer
| package main
import "fmt"
func main() {
outer:
for i := 0; i < 4; i++ {
for j := 0; j < 4; j++ {
if i + j == 4 { continue outer }
if i + j == 5 { break outer }
fmt.Println(i + j)
}
}
k := 3
if k == 3 { goto later }
fmt.Println(k)
later:
k++
fmt.Println(k)
}
|
Write a version of this Nim function in Go with identical behavior. | block outer:
for i in 0..1000:
for j in 0..1000:
if i + j == 3:
break outer
| package main
import "fmt"
func main() {
outer:
for i := 0; i < 4; i++ {
for j := 0; j < 4; j++ {
if i + j == 4 { continue outer }
if i + j == 5 { break outer }
fmt.Println(i + j)
}
}
k := 3
if k == 3 { goto later }
fmt.Println(k)
later:
k++
fmt.Println(k)
}
|
Produce a language-to-language conversion: from Perl to C, same semantics. | sub outer {
print "In outer, calling inner:\n";
inner();
OUTER:
print "at label OUTER\n";
}
sub inner {
print "In inner\n";
goto SKIP;
print "This should be skipped\n";
SKIP:
print "at label SKIP\n";
goto OUTER;
print "Inner should never reach here\n";
}
sub disguise {
goto &outer;
print "Can't reach this statement\n";
}
print "Calling outer:\n";
outer();
print "\nCalling disguise:\n";
disguise();
print "\nCalling inner:\n";
inner();
| if (x > 0) goto positive;
else goto negative;
positive:
printf("pos\n"); goto both;
negative:
printf("neg\n");
both:
...
|
Rewrite the snippet below in C so it works the same as the original Perl code. | sub outer {
print "In outer, calling inner:\n";
inner();
OUTER:
print "at label OUTER\n";
}
sub inner {
print "In inner\n";
goto SKIP;
print "This should be skipped\n";
SKIP:
print "at label SKIP\n";
goto OUTER;
print "Inner should never reach here\n";
}
sub disguise {
goto &outer;
print "Can't reach this statement\n";
}
print "Calling outer:\n";
outer();
print "\nCalling disguise:\n";
disguise();
print "\nCalling inner:\n";
inner();
| if (x > 0) goto positive;
else goto negative;
positive:
printf("pos\n"); goto both;
negative:
printf("neg\n");
both:
...
|
Keep all operations the same but rewrite the snippet in C#. | sub outer {
print "In outer, calling inner:\n";
inner();
OUTER:
print "at label OUTER\n";
}
sub inner {
print "In inner\n";
goto SKIP;
print "This should be skipped\n";
SKIP:
print "at label SKIP\n";
goto OUTER;
print "Inner should never reach here\n";
}
sub disguise {
goto &outer;
print "Can't reach this statement\n";
}
print "Calling outer:\n";
outer();
print "\nCalling disguise:\n";
disguise();
print "\nCalling inner:\n";
inner();
| if (x > 0) goto positive;
else goto negative;
positive:
Console.WriteLine("pos\n"); goto both;
negative:
Console.WriteLine("neg\n");
both:
...
|
Rewrite the snippet below in C# so it works the same as the original Perl code. | sub outer {
print "In outer, calling inner:\n";
inner();
OUTER:
print "at label OUTER\n";
}
sub inner {
print "In inner\n";
goto SKIP;
print "This should be skipped\n";
SKIP:
print "at label SKIP\n";
goto OUTER;
print "Inner should never reach here\n";
}
sub disguise {
goto &outer;
print "Can't reach this statement\n";
}
print "Calling outer:\n";
outer();
print "\nCalling disguise:\n";
disguise();
print "\nCalling inner:\n";
inner();
| if (x > 0) goto positive;
else goto negative;
positive:
Console.WriteLine("pos\n"); goto both;
negative:
Console.WriteLine("neg\n");
both:
...
|
Produce a language-to-language conversion: from Perl to C++, same semantics. | sub outer {
print "In outer, calling inner:\n";
inner();
OUTER:
print "at label OUTER\n";
}
sub inner {
print "In inner\n";
goto SKIP;
print "This should be skipped\n";
SKIP:
print "at label SKIP\n";
goto OUTER;
print "Inner should never reach here\n";
}
sub disguise {
goto &outer;
print "Can't reach this statement\n";
}
print "Calling outer:\n";
outer();
print "\nCalling disguise:\n";
disguise();
print "\nCalling inner:\n";
inner();
| #include <iostream>
#include <utility>
using namespace std;
int main(void)
{
cout << "Find a solution to i = 2 * j - 7\n";
pair<int, int> answer;
for(int i = 0; true; i++)
{
for(int j = 0; j < i; j++)
{
if( i == 2 * j - 7)
{
answer = make_pair(i, j);
goto loopexit;
}
}
}
loopexit:
cout << answer.first << " = 2 * " << answer.second << " - 7\n\n";
goto spagetti;
int k;
k = 9;
spagetti:
cout << "k = " << k << "\n";
}
|
Produce a functionally identical C++ code for the snippet given in Perl. | sub outer {
print "In outer, calling inner:\n";
inner();
OUTER:
print "at label OUTER\n";
}
sub inner {
print "In inner\n";
goto SKIP;
print "This should be skipped\n";
SKIP:
print "at label SKIP\n";
goto OUTER;
print "Inner should never reach here\n";
}
sub disguise {
goto &outer;
print "Can't reach this statement\n";
}
print "Calling outer:\n";
outer();
print "\nCalling disguise:\n";
disguise();
print "\nCalling inner:\n";
inner();
| #include <iostream>
#include <utility>
using namespace std;
int main(void)
{
cout << "Find a solution to i = 2 * j - 7\n";
pair<int, int> answer;
for(int i = 0; true; i++)
{
for(int j = 0; j < i; j++)
{
if( i == 2 * j - 7)
{
answer = make_pair(i, j);
goto loopexit;
}
}
}
loopexit:
cout << answer.first << " = 2 * " << answer.second << " - 7\n\n";
goto spagetti;
int k;
k = 9;
spagetti:
cout << "k = " << k << "\n";
}
|
Maintain the same structure and functionality when rewriting this code in Java. | sub outer {
print "In outer, calling inner:\n";
inner();
OUTER:
print "at label OUTER\n";
}
sub inner {
print "In inner\n";
goto SKIP;
print "This should be skipped\n";
SKIP:
print "at label SKIP\n";
goto OUTER;
print "Inner should never reach here\n";
}
sub disguise {
goto &outer;
print "Can't reach this statement\n";
}
print "Calling outer:\n";
outer();
print "\nCalling disguise:\n";
disguise();
print "\nCalling inner:\n";
inner();
| loop1: while (x != 0) {
loop2: for (int i = 0; i < 10; i++) {
loop3: do {
if () {
continue loop1;
}
if () {
break loop2;
}
} while (y < 10);
}
}
|
Can you help me rewrite this code in Java instead of Perl, keeping it the same logically? | sub outer {
print "In outer, calling inner:\n";
inner();
OUTER:
print "at label OUTER\n";
}
sub inner {
print "In inner\n";
goto SKIP;
print "This should be skipped\n";
SKIP:
print "at label SKIP\n";
goto OUTER;
print "Inner should never reach here\n";
}
sub disguise {
goto &outer;
print "Can't reach this statement\n";
}
print "Calling outer:\n";
outer();
print "\nCalling disguise:\n";
disguise();
print "\nCalling inner:\n";
inner();
| loop1: while (x != 0) {
loop2: for (int i = 0; i < 10; i++) {
loop3: do {
if () {
continue loop1;
}
if () {
break loop2;
}
} while (y < 10);
}
}
|
Ensure the translated Python code behaves exactly like the original Perl snippet. | sub outer {
print "In outer, calling inner:\n";
inner();
OUTER:
print "at label OUTER\n";
}
sub inner {
print "In inner\n";
goto SKIP;
print "This should be skipped\n";
SKIP:
print "at label SKIP\n";
goto OUTER;
print "Inner should never reach here\n";
}
sub disguise {
goto &outer;
print "Can't reach this statement\n";
}
print "Calling outer:\n";
outer();
print "\nCalling disguise:\n";
disguise();
print "\nCalling inner:\n";
inner();
|
from goto import goto, label
label .start
for i in range(1, 4):
print i
if i == 2:
try:
output = message
except NameError:
print "Oops - forgot to define 'message'! Start again."
message = "Hello world"
goto .start
print output, "\n"
|
Change the following Perl code into Python without altering its purpose. | sub outer {
print "In outer, calling inner:\n";
inner();
OUTER:
print "at label OUTER\n";
}
sub inner {
print "In inner\n";
goto SKIP;
print "This should be skipped\n";
SKIP:
print "at label SKIP\n";
goto OUTER;
print "Inner should never reach here\n";
}
sub disguise {
goto &outer;
print "Can't reach this statement\n";
}
print "Calling outer:\n";
outer();
print "\nCalling disguise:\n";
disguise();
print "\nCalling inner:\n";
inner();
|
from goto import goto, label
label .start
for i in range(1, 4):
print i
if i == 2:
try:
output = message
except NameError:
print "Oops - forgot to define 'message'! Start again."
message = "Hello world"
goto .start
print output, "\n"
|
Change the following Perl code into VB without altering its purpose. | sub outer {
print "In outer, calling inner:\n";
inner();
OUTER:
print "at label OUTER\n";
}
sub inner {
print "In inner\n";
goto SKIP;
print "This should be skipped\n";
SKIP:
print "at label SKIP\n";
goto OUTER;
print "Inner should never reach here\n";
}
sub disguise {
goto &outer;
print "Can't reach this statement\n";
}
print "Calling outer:\n";
outer();
print "\nCalling disguise:\n";
disguise();
print "\nCalling inner:\n";
inner();
| Public Sub jump()
Debug.Print "VBA only allows"
GoTo 1
Debug.Print "no global jumps"
1:
Debug.Print "jumps in procedures with GoTo"
Debug.Print "However,"
On 2 GoSub one, two
Debug.Print "named in the list after
Debug.Print "and execution will continue on the next line"
On 1 GoTo one, two
Debug.Print "For On Error, see Exceptions"
one:
Debug.Print "On <n> GoTo let you jump to the n-th label"
Debug.Print "and won
Exit Sub
two:
Debug.Print "On <n> GoSub let you jump to the n-th label": Return
End Sub
|
Change the programming language of this snippet from Perl to VB without modifying what it does. | sub outer {
print "In outer, calling inner:\n";
inner();
OUTER:
print "at label OUTER\n";
}
sub inner {
print "In inner\n";
goto SKIP;
print "This should be skipped\n";
SKIP:
print "at label SKIP\n";
goto OUTER;
print "Inner should never reach here\n";
}
sub disguise {
goto &outer;
print "Can't reach this statement\n";
}
print "Calling outer:\n";
outer();
print "\nCalling disguise:\n";
disguise();
print "\nCalling inner:\n";
inner();
| Public Sub jump()
Debug.Print "VBA only allows"
GoTo 1
Debug.Print "no global jumps"
1:
Debug.Print "jumps in procedures with GoTo"
Debug.Print "However,"
On 2 GoSub one, two
Debug.Print "named in the list after
Debug.Print "and execution will continue on the next line"
On 1 GoTo one, two
Debug.Print "For On Error, see Exceptions"
one:
Debug.Print "On <n> GoTo let you jump to the n-th label"
Debug.Print "and won
Exit Sub
two:
Debug.Print "On <n> GoSub let you jump to the n-th label": Return
End Sub
|
Generate a Go translation of this Perl snippet without changing its computational steps. | sub outer {
print "In outer, calling inner:\n";
inner();
OUTER:
print "at label OUTER\n";
}
sub inner {
print "In inner\n";
goto SKIP;
print "This should be skipped\n";
SKIP:
print "at label SKIP\n";
goto OUTER;
print "Inner should never reach here\n";
}
sub disguise {
goto &outer;
print "Can't reach this statement\n";
}
print "Calling outer:\n";
outer();
print "\nCalling disguise:\n";
disguise();
print "\nCalling inner:\n";
inner();
| package main
import "fmt"
func main() {
outer:
for i := 0; i < 4; i++ {
for j := 0; j < 4; j++ {
if i + j == 4 { continue outer }
if i + j == 5 { break outer }
fmt.Println(i + j)
}
}
k := 3
if k == 3 { goto later }
fmt.Println(k)
later:
k++
fmt.Println(k)
}
|
Write the same algorithm in Go as shown in this Perl implementation. | sub outer {
print "In outer, calling inner:\n";
inner();
OUTER:
print "at label OUTER\n";
}
sub inner {
print "In inner\n";
goto SKIP;
print "This should be skipped\n";
SKIP:
print "at label SKIP\n";
goto OUTER;
print "Inner should never reach here\n";
}
sub disguise {
goto &outer;
print "Can't reach this statement\n";
}
print "Calling outer:\n";
outer();
print "\nCalling disguise:\n";
disguise();
print "\nCalling inner:\n";
inner();
| package main
import "fmt"
func main() {
outer:
for i := 0; i < 4; i++ {
for j := 0; j < 4; j++ {
if i + j == 4 { continue outer }
if i + j == 5 { break outer }
fmt.Println(i + j)
}
}
k := 3
if k == 3 { goto later }
fmt.Println(k)
later:
k++
fmt.Println(k)
}
|
Write a version of this PowerShell function in C with identical behavior. | :myLabel while (<condition>) { <statement list>}
| if (x > 0) goto positive;
else goto negative;
positive:
printf("pos\n"); goto both;
negative:
printf("neg\n");
both:
...
|
Produce a language-to-language conversion: from PowerShell to C, same semantics. | :myLabel while (<condition>) { <statement list>}
| if (x > 0) goto positive;
else goto negative;
positive:
printf("pos\n"); goto both;
negative:
printf("neg\n");
both:
...
|
Preserve the algorithm and functionality while converting the code from PowerShell to C#. | :myLabel while (<condition>) { <statement list>}
| if (x > 0) goto positive;
else goto negative;
positive:
Console.WriteLine("pos\n"); goto both;
negative:
Console.WriteLine("neg\n");
both:
...
|
Transform the following PowerShell implementation into C#, maintaining the same output and logic. | :myLabel while (<condition>) { <statement list>}
| if (x > 0) goto positive;
else goto negative;
positive:
Console.WriteLine("pos\n"); goto both;
negative:
Console.WriteLine("neg\n");
both:
...
|
Convert the following code from PowerShell to C++, ensuring the logic remains intact. | :myLabel while (<condition>) { <statement list>}
| #include <iostream>
#include <utility>
using namespace std;
int main(void)
{
cout << "Find a solution to i = 2 * j - 7\n";
pair<int, int> answer;
for(int i = 0; true; i++)
{
for(int j = 0; j < i; j++)
{
if( i == 2 * j - 7)
{
answer = make_pair(i, j);
goto loopexit;
}
}
}
loopexit:
cout << answer.first << " = 2 * " << answer.second << " - 7\n\n";
goto spagetti;
int k;
k = 9;
spagetti:
cout << "k = " << k << "\n";
}
|
Convert this PowerShell snippet to C++ and keep its semantics consistent. | :myLabel while (<condition>) { <statement list>}
| #include <iostream>
#include <utility>
using namespace std;
int main(void)
{
cout << "Find a solution to i = 2 * j - 7\n";
pair<int, int> answer;
for(int i = 0; true; i++)
{
for(int j = 0; j < i; j++)
{
if( i == 2 * j - 7)
{
answer = make_pair(i, j);
goto loopexit;
}
}
}
loopexit:
cout << answer.first << " = 2 * " << answer.second << " - 7\n\n";
goto spagetti;
int k;
k = 9;
spagetti:
cout << "k = " << k << "\n";
}
|
Translate this program into Java but keep the logic exactly as in PowerShell. | :myLabel while (<condition>) { <statement list>}
| loop1: while (x != 0) {
loop2: for (int i = 0; i < 10; i++) {
loop3: do {
if () {
continue loop1;
}
if () {
break loop2;
}
} while (y < 10);
}
}
|
Translate this program into Java but keep the logic exactly as in PowerShell. | :myLabel while (<condition>) { <statement list>}
| loop1: while (x != 0) {
loop2: for (int i = 0; i < 10; i++) {
loop3: do {
if () {
continue loop1;
}
if () {
break loop2;
}
} while (y < 10);
}
}
|
Write the same code in Python as shown below in PowerShell. | :myLabel while (<condition>) { <statement list>}
|
from goto import goto, label
label .start
for i in range(1, 4):
print i
if i == 2:
try:
output = message
except NameError:
print "Oops - forgot to define 'message'! Start again."
message = "Hello world"
goto .start
print output, "\n"
|
Write the same code in Python as shown below in PowerShell. | :myLabel while (<condition>) { <statement list>}
|
from goto import goto, label
label .start
for i in range(1, 4):
print i
if i == 2:
try:
output = message
except NameError:
print "Oops - forgot to define 'message'! Start again."
message = "Hello world"
goto .start
print output, "\n"
|
Write a version of this PowerShell function in VB with identical behavior. | :myLabel while (<condition>) { <statement list>}
| Public Sub jump()
Debug.Print "VBA only allows"
GoTo 1
Debug.Print "no global jumps"
1:
Debug.Print "jumps in procedures with GoTo"
Debug.Print "However,"
On 2 GoSub one, two
Debug.Print "named in the list after
Debug.Print "and execution will continue on the next line"
On 1 GoTo one, two
Debug.Print "For On Error, see Exceptions"
one:
Debug.Print "On <n> GoTo let you jump to the n-th label"
Debug.Print "and won
Exit Sub
two:
Debug.Print "On <n> GoSub let you jump to the n-th label": Return
End Sub
|
Convert this PowerShell block to VB, preserving its control flow and logic. | :myLabel while (<condition>) { <statement list>}
| Public Sub jump()
Debug.Print "VBA only allows"
GoTo 1
Debug.Print "no global jumps"
1:
Debug.Print "jumps in procedures with GoTo"
Debug.Print "However,"
On 2 GoSub one, two
Debug.Print "named in the list after
Debug.Print "and execution will continue on the next line"
On 1 GoTo one, two
Debug.Print "For On Error, see Exceptions"
one:
Debug.Print "On <n> GoTo let you jump to the n-th label"
Debug.Print "and won
Exit Sub
two:
Debug.Print "On <n> GoSub let you jump to the n-th label": Return
End Sub
|
Convert this PowerShell snippet to Go and keep its semantics consistent. | :myLabel while (<condition>) { <statement list>}
| package main
import "fmt"
func main() {
outer:
for i := 0; i < 4; i++ {
for j := 0; j < 4; j++ {
if i + j == 4 { continue outer }
if i + j == 5 { break outer }
fmt.Println(i + j)
}
}
k := 3
if k == 3 { goto later }
fmt.Println(k)
later:
k++
fmt.Println(k)
}
|
Generate an equivalent Go version of this PowerShell code. | :myLabel while (<condition>) { <statement list>}
| package main
import "fmt"
func main() {
outer:
for i := 0; i < 4; i++ {
for j := 0; j < 4; j++ {
if i + j == 4 { continue outer }
if i + j == 5 { break outer }
fmt.Println(i + j)
}
}
k := 3
if k == 3 { goto later }
fmt.Println(k)
later:
k++
fmt.Println(k)
}
|
Change the following Racket code into C without altering its purpose. | #lang racket
(define (never-divides-by-zero return)
(displayln "I'm here")
(return "Leaving")
(displayln "Never going to reach this")
(/ 1 0))
(call/cc never-divides-by-zero)
| if (x > 0) goto positive;
else goto negative;
positive:
printf("pos\n"); goto both;
negative:
printf("neg\n");
both:
...
|
Preserve the algorithm and functionality while converting the code from Racket to C. | #lang racket
(define (never-divides-by-zero return)
(displayln "I'm here")
(return "Leaving")
(displayln "Never going to reach this")
(/ 1 0))
(call/cc never-divides-by-zero)
| if (x > 0) goto positive;
else goto negative;
positive:
printf("pos\n"); goto both;
negative:
printf("neg\n");
both:
...
|
Keep all operations the same but rewrite the snippet in C#. | #lang racket
(define (never-divides-by-zero return)
(displayln "I'm here")
(return "Leaving")
(displayln "Never going to reach this")
(/ 1 0))
(call/cc never-divides-by-zero)
| if (x > 0) goto positive;
else goto negative;
positive:
Console.WriteLine("pos\n"); goto both;
negative:
Console.WriteLine("neg\n");
both:
...
|
Change the following Racket code into C# without altering its purpose. | #lang racket
(define (never-divides-by-zero return)
(displayln "I'm here")
(return "Leaving")
(displayln "Never going to reach this")
(/ 1 0))
(call/cc never-divides-by-zero)
| if (x > 0) goto positive;
else goto negative;
positive:
Console.WriteLine("pos\n"); goto both;
negative:
Console.WriteLine("neg\n");
both:
...
|
Change the following Racket code into C++ without altering its purpose. | #lang racket
(define (never-divides-by-zero return)
(displayln "I'm here")
(return "Leaving")
(displayln "Never going to reach this")
(/ 1 0))
(call/cc never-divides-by-zero)
| #include <iostream>
#include <utility>
using namespace std;
int main(void)
{
cout << "Find a solution to i = 2 * j - 7\n";
pair<int, int> answer;
for(int i = 0; true; i++)
{
for(int j = 0; j < i; j++)
{
if( i == 2 * j - 7)
{
answer = make_pair(i, j);
goto loopexit;
}
}
}
loopexit:
cout << answer.first << " = 2 * " << answer.second << " - 7\n\n";
goto spagetti;
int k;
k = 9;
spagetti:
cout << "k = " << k << "\n";
}
|
Ensure the translated C++ code behaves exactly like the original Racket snippet. | #lang racket
(define (never-divides-by-zero return)
(displayln "I'm here")
(return "Leaving")
(displayln "Never going to reach this")
(/ 1 0))
(call/cc never-divides-by-zero)
| #include <iostream>
#include <utility>
using namespace std;
int main(void)
{
cout << "Find a solution to i = 2 * j - 7\n";
pair<int, int> answer;
for(int i = 0; true; i++)
{
for(int j = 0; j < i; j++)
{
if( i == 2 * j - 7)
{
answer = make_pair(i, j);
goto loopexit;
}
}
}
loopexit:
cout << answer.first << " = 2 * " << answer.second << " - 7\n\n";
goto spagetti;
int k;
k = 9;
spagetti:
cout << "k = " << k << "\n";
}
|
Rewrite this program in Java while keeping its functionality equivalent to the Racket version. | #lang racket
(define (never-divides-by-zero return)
(displayln "I'm here")
(return "Leaving")
(displayln "Never going to reach this")
(/ 1 0))
(call/cc never-divides-by-zero)
| loop1: while (x != 0) {
loop2: for (int i = 0; i < 10; i++) {
loop3: do {
if () {
continue loop1;
}
if () {
break loop2;
}
} while (y < 10);
}
}
|
Rewrite this program in Java while keeping its functionality equivalent to the Racket version. | #lang racket
(define (never-divides-by-zero return)
(displayln "I'm here")
(return "Leaving")
(displayln "Never going to reach this")
(/ 1 0))
(call/cc never-divides-by-zero)
| loop1: while (x != 0) {
loop2: for (int i = 0; i < 10; i++) {
loop3: do {
if () {
continue loop1;
}
if () {
break loop2;
}
} while (y < 10);
}
}
|
Write the same code in Python as shown below in Racket. | #lang racket
(define (never-divides-by-zero return)
(displayln "I'm here")
(return "Leaving")
(displayln "Never going to reach this")
(/ 1 0))
(call/cc never-divides-by-zero)
|
from goto import goto, label
label .start
for i in range(1, 4):
print i
if i == 2:
try:
output = message
except NameError:
print "Oops - forgot to define 'message'! Start again."
message = "Hello world"
goto .start
print output, "\n"
|
Transform the following Racket implementation into Python, maintaining the same output and logic. | #lang racket
(define (never-divides-by-zero return)
(displayln "I'm here")
(return "Leaving")
(displayln "Never going to reach this")
(/ 1 0))
(call/cc never-divides-by-zero)
|
from goto import goto, label
label .start
for i in range(1, 4):
print i
if i == 2:
try:
output = message
except NameError:
print "Oops - forgot to define 'message'! Start again."
message = "Hello world"
goto .start
print output, "\n"
|
Produce a language-to-language conversion: from Racket to VB, same semantics. | #lang racket
(define (never-divides-by-zero return)
(displayln "I'm here")
(return "Leaving")
(displayln "Never going to reach this")
(/ 1 0))
(call/cc never-divides-by-zero)
| Public Sub jump()
Debug.Print "VBA only allows"
GoTo 1
Debug.Print "no global jumps"
1:
Debug.Print "jumps in procedures with GoTo"
Debug.Print "However,"
On 2 GoSub one, two
Debug.Print "named in the list after
Debug.Print "and execution will continue on the next line"
On 1 GoTo one, two
Debug.Print "For On Error, see Exceptions"
one:
Debug.Print "On <n> GoTo let you jump to the n-th label"
Debug.Print "and won
Exit Sub
two:
Debug.Print "On <n> GoSub let you jump to the n-th label": Return
End Sub
|
Rewrite the snippet below in VB so it works the same as the original Racket code. | #lang racket
(define (never-divides-by-zero return)
(displayln "I'm here")
(return "Leaving")
(displayln "Never going to reach this")
(/ 1 0))
(call/cc never-divides-by-zero)
| Public Sub jump()
Debug.Print "VBA only allows"
GoTo 1
Debug.Print "no global jumps"
1:
Debug.Print "jumps in procedures with GoTo"
Debug.Print "However,"
On 2 GoSub one, two
Debug.Print "named in the list after
Debug.Print "and execution will continue on the next line"
On 1 GoTo one, two
Debug.Print "For On Error, see Exceptions"
one:
Debug.Print "On <n> GoTo let you jump to the n-th label"
Debug.Print "and won
Exit Sub
two:
Debug.Print "On <n> GoSub let you jump to the n-th label": Return
End Sub
|
Write the same code in Go as shown below in Racket. | #lang racket
(define (never-divides-by-zero return)
(displayln "I'm here")
(return "Leaving")
(displayln "Never going to reach this")
(/ 1 0))
(call/cc never-divides-by-zero)
| package main
import "fmt"
func main() {
outer:
for i := 0; i < 4; i++ {
for j := 0; j < 4; j++ {
if i + j == 4 { continue outer }
if i + j == 5 { break outer }
fmt.Println(i + j)
}
}
k := 3
if k == 3 { goto later }
fmt.Println(k)
later:
k++
fmt.Println(k)
}
|
Rewrite this program in Go while keeping its functionality equivalent to the Racket version. | #lang racket
(define (never-divides-by-zero return)
(displayln "I'm here")
(return "Leaving")
(displayln "Never going to reach this")
(/ 1 0))
(call/cc never-divides-by-zero)
| package main
import "fmt"
func main() {
outer:
for i := 0; i < 4; i++ {
for j := 0; j < 4; j++ {
if i + j == 4 { continue outer }
if i + j == 5 { break outer }
fmt.Println(i + j)
}
}
k := 3
if k == 3 { goto later }
fmt.Println(k)
later:
k++
fmt.Println(k)
}
|
Generate an equivalent C version of this COBOL code. | IDENTIFICATION DIVISION.
PROGRAM-ID. JUMPS-PROGRAM.
* Nobody writes like this, of course; but...
PROCEDURE DIVISION.
* You can jump anywhere you like.
START-PARAGRAPH.
GO TO AN-ARBITRARY-PARAGRAPH.
YET-ANOTHER-PARAGRAPH.
ALTER START-PARAGRAPH TO PROCEED TO A-PARAGRAPH-SOMEWHERE.
* That's right, folks: we don't just have GO TOs, we have GO TOs whose
* destinations can be changed at will, from anywhere in the program,
* at run time.
GO TO START-PARAGRAPH.
* But bear in mind: once you get there, the GO TO no longer goes to
* where it says it goes to.
A-PARAGRAPH-SOMEWHERE.
DISPLAY 'Never heard of him.'
STOP RUN.
SOME-OTHER-PARAGRAPH.
* You think that's bad? You ain't seen nothing.
GO TO YET-ANOTHER-PARAGRAPH.
AN-ARBITRARY-PARAGRAPH.
DISPLAY 'Edsger who now?'
GO TO SOME-OTHER-PARAGRAPH.
| if (x > 0) goto positive;
else goto negative;
positive:
printf("pos\n"); goto both;
negative:
printf("neg\n");
both:
...
|
Rewrite this program in C while keeping its functionality equivalent to the COBOL version. | IDENTIFICATION DIVISION.
PROGRAM-ID. JUMPS-PROGRAM.
* Nobody writes like this, of course; but...
PROCEDURE DIVISION.
* You can jump anywhere you like.
START-PARAGRAPH.
GO TO AN-ARBITRARY-PARAGRAPH.
YET-ANOTHER-PARAGRAPH.
ALTER START-PARAGRAPH TO PROCEED TO A-PARAGRAPH-SOMEWHERE.
* That's right, folks: we don't just have GO TOs, we have GO TOs whose
* destinations can be changed at will, from anywhere in the program,
* at run time.
GO TO START-PARAGRAPH.
* But bear in mind: once you get there, the GO TO no longer goes to
* where it says it goes to.
A-PARAGRAPH-SOMEWHERE.
DISPLAY 'Never heard of him.'
STOP RUN.
SOME-OTHER-PARAGRAPH.
* You think that's bad? You ain't seen nothing.
GO TO YET-ANOTHER-PARAGRAPH.
AN-ARBITRARY-PARAGRAPH.
DISPLAY 'Edsger who now?'
GO TO SOME-OTHER-PARAGRAPH.
| if (x > 0) goto positive;
else goto negative;
positive:
printf("pos\n"); goto both;
negative:
printf("neg\n");
both:
...
|
Maintain the same structure and functionality when rewriting this code in C#. | IDENTIFICATION DIVISION.
PROGRAM-ID. JUMPS-PROGRAM.
* Nobody writes like this, of course; but...
PROCEDURE DIVISION.
* You can jump anywhere you like.
START-PARAGRAPH.
GO TO AN-ARBITRARY-PARAGRAPH.
YET-ANOTHER-PARAGRAPH.
ALTER START-PARAGRAPH TO PROCEED TO A-PARAGRAPH-SOMEWHERE.
* That's right, folks: we don't just have GO TOs, we have GO TOs whose
* destinations can be changed at will, from anywhere in the program,
* at run time.
GO TO START-PARAGRAPH.
* But bear in mind: once you get there, the GO TO no longer goes to
* where it says it goes to.
A-PARAGRAPH-SOMEWHERE.
DISPLAY 'Never heard of him.'
STOP RUN.
SOME-OTHER-PARAGRAPH.
* You think that's bad? You ain't seen nothing.
GO TO YET-ANOTHER-PARAGRAPH.
AN-ARBITRARY-PARAGRAPH.
DISPLAY 'Edsger who now?'
GO TO SOME-OTHER-PARAGRAPH.
| if (x > 0) goto positive;
else goto negative;
positive:
Console.WriteLine("pos\n"); goto both;
negative:
Console.WriteLine("neg\n");
both:
...
|
Rewrite this program in C# while keeping its functionality equivalent to the COBOL version. | IDENTIFICATION DIVISION.
PROGRAM-ID. JUMPS-PROGRAM.
* Nobody writes like this, of course; but...
PROCEDURE DIVISION.
* You can jump anywhere you like.
START-PARAGRAPH.
GO TO AN-ARBITRARY-PARAGRAPH.
YET-ANOTHER-PARAGRAPH.
ALTER START-PARAGRAPH TO PROCEED TO A-PARAGRAPH-SOMEWHERE.
* That's right, folks: we don't just have GO TOs, we have GO TOs whose
* destinations can be changed at will, from anywhere in the program,
* at run time.
GO TO START-PARAGRAPH.
* But bear in mind: once you get there, the GO TO no longer goes to
* where it says it goes to.
A-PARAGRAPH-SOMEWHERE.
DISPLAY 'Never heard of him.'
STOP RUN.
SOME-OTHER-PARAGRAPH.
* You think that's bad? You ain't seen nothing.
GO TO YET-ANOTHER-PARAGRAPH.
AN-ARBITRARY-PARAGRAPH.
DISPLAY 'Edsger who now?'
GO TO SOME-OTHER-PARAGRAPH.
| if (x > 0) goto positive;
else goto negative;
positive:
Console.WriteLine("pos\n"); goto both;
negative:
Console.WriteLine("neg\n");
both:
...
|
Change the programming language of this snippet from COBOL to C++ without modifying what it does. | IDENTIFICATION DIVISION.
PROGRAM-ID. JUMPS-PROGRAM.
* Nobody writes like this, of course; but...
PROCEDURE DIVISION.
* You can jump anywhere you like.
START-PARAGRAPH.
GO TO AN-ARBITRARY-PARAGRAPH.
YET-ANOTHER-PARAGRAPH.
ALTER START-PARAGRAPH TO PROCEED TO A-PARAGRAPH-SOMEWHERE.
* That's right, folks: we don't just have GO TOs, we have GO TOs whose
* destinations can be changed at will, from anywhere in the program,
* at run time.
GO TO START-PARAGRAPH.
* But bear in mind: once you get there, the GO TO no longer goes to
* where it says it goes to.
A-PARAGRAPH-SOMEWHERE.
DISPLAY 'Never heard of him.'
STOP RUN.
SOME-OTHER-PARAGRAPH.
* You think that's bad? You ain't seen nothing.
GO TO YET-ANOTHER-PARAGRAPH.
AN-ARBITRARY-PARAGRAPH.
DISPLAY 'Edsger who now?'
GO TO SOME-OTHER-PARAGRAPH.
| #include <iostream>
#include <utility>
using namespace std;
int main(void)
{
cout << "Find a solution to i = 2 * j - 7\n";
pair<int, int> answer;
for(int i = 0; true; i++)
{
for(int j = 0; j < i; j++)
{
if( i == 2 * j - 7)
{
answer = make_pair(i, j);
goto loopexit;
}
}
}
loopexit:
cout << answer.first << " = 2 * " << answer.second << " - 7\n\n";
goto spagetti;
int k;
k = 9;
spagetti:
cout << "k = " << k << "\n";
}
|
Translate this program into C++ but keep the logic exactly as in COBOL. | IDENTIFICATION DIVISION.
PROGRAM-ID. JUMPS-PROGRAM.
* Nobody writes like this, of course; but...
PROCEDURE DIVISION.
* You can jump anywhere you like.
START-PARAGRAPH.
GO TO AN-ARBITRARY-PARAGRAPH.
YET-ANOTHER-PARAGRAPH.
ALTER START-PARAGRAPH TO PROCEED TO A-PARAGRAPH-SOMEWHERE.
* That's right, folks: we don't just have GO TOs, we have GO TOs whose
* destinations can be changed at will, from anywhere in the program,
* at run time.
GO TO START-PARAGRAPH.
* But bear in mind: once you get there, the GO TO no longer goes to
* where it says it goes to.
A-PARAGRAPH-SOMEWHERE.
DISPLAY 'Never heard of him.'
STOP RUN.
SOME-OTHER-PARAGRAPH.
* You think that's bad? You ain't seen nothing.
GO TO YET-ANOTHER-PARAGRAPH.
AN-ARBITRARY-PARAGRAPH.
DISPLAY 'Edsger who now?'
GO TO SOME-OTHER-PARAGRAPH.
| #include <iostream>
#include <utility>
using namespace std;
int main(void)
{
cout << "Find a solution to i = 2 * j - 7\n";
pair<int, int> answer;
for(int i = 0; true; i++)
{
for(int j = 0; j < i; j++)
{
if( i == 2 * j - 7)
{
answer = make_pair(i, j);
goto loopexit;
}
}
}
loopexit:
cout << answer.first << " = 2 * " << answer.second << " - 7\n\n";
goto spagetti;
int k;
k = 9;
spagetti:
cout << "k = " << k << "\n";
}
|
Transform the following COBOL implementation into Java, maintaining the same output and logic. | IDENTIFICATION DIVISION.
PROGRAM-ID. JUMPS-PROGRAM.
* Nobody writes like this, of course; but...
PROCEDURE DIVISION.
* You can jump anywhere you like.
START-PARAGRAPH.
GO TO AN-ARBITRARY-PARAGRAPH.
YET-ANOTHER-PARAGRAPH.
ALTER START-PARAGRAPH TO PROCEED TO A-PARAGRAPH-SOMEWHERE.
* That's right, folks: we don't just have GO TOs, we have GO TOs whose
* destinations can be changed at will, from anywhere in the program,
* at run time.
GO TO START-PARAGRAPH.
* But bear in mind: once you get there, the GO TO no longer goes to
* where it says it goes to.
A-PARAGRAPH-SOMEWHERE.
DISPLAY 'Never heard of him.'
STOP RUN.
SOME-OTHER-PARAGRAPH.
* You think that's bad? You ain't seen nothing.
GO TO YET-ANOTHER-PARAGRAPH.
AN-ARBITRARY-PARAGRAPH.
DISPLAY 'Edsger who now?'
GO TO SOME-OTHER-PARAGRAPH.
| loop1: while (x != 0) {
loop2: for (int i = 0; i < 10; i++) {
loop3: do {
if () {
continue loop1;
}
if () {
break loop2;
}
} while (y < 10);
}
}
|
Preserve the algorithm and functionality while converting the code from COBOL to Java. | IDENTIFICATION DIVISION.
PROGRAM-ID. JUMPS-PROGRAM.
* Nobody writes like this, of course; but...
PROCEDURE DIVISION.
* You can jump anywhere you like.
START-PARAGRAPH.
GO TO AN-ARBITRARY-PARAGRAPH.
YET-ANOTHER-PARAGRAPH.
ALTER START-PARAGRAPH TO PROCEED TO A-PARAGRAPH-SOMEWHERE.
* That's right, folks: we don't just have GO TOs, we have GO TOs whose
* destinations can be changed at will, from anywhere in the program,
* at run time.
GO TO START-PARAGRAPH.
* But bear in mind: once you get there, the GO TO no longer goes to
* where it says it goes to.
A-PARAGRAPH-SOMEWHERE.
DISPLAY 'Never heard of him.'
STOP RUN.
SOME-OTHER-PARAGRAPH.
* You think that's bad? You ain't seen nothing.
GO TO YET-ANOTHER-PARAGRAPH.
AN-ARBITRARY-PARAGRAPH.
DISPLAY 'Edsger who now?'
GO TO SOME-OTHER-PARAGRAPH.
| loop1: while (x != 0) {
loop2: for (int i = 0; i < 10; i++) {
loop3: do {
if () {
continue loop1;
}
if () {
break loop2;
}
} while (y < 10);
}
}
|
Change the following COBOL code into Python without altering its purpose. | IDENTIFICATION DIVISION.
PROGRAM-ID. JUMPS-PROGRAM.
* Nobody writes like this, of course; but...
PROCEDURE DIVISION.
* You can jump anywhere you like.
START-PARAGRAPH.
GO TO AN-ARBITRARY-PARAGRAPH.
YET-ANOTHER-PARAGRAPH.
ALTER START-PARAGRAPH TO PROCEED TO A-PARAGRAPH-SOMEWHERE.
* That's right, folks: we don't just have GO TOs, we have GO TOs whose
* destinations can be changed at will, from anywhere in the program,
* at run time.
GO TO START-PARAGRAPH.
* But bear in mind: once you get there, the GO TO no longer goes to
* where it says it goes to.
A-PARAGRAPH-SOMEWHERE.
DISPLAY 'Never heard of him.'
STOP RUN.
SOME-OTHER-PARAGRAPH.
* You think that's bad? You ain't seen nothing.
GO TO YET-ANOTHER-PARAGRAPH.
AN-ARBITRARY-PARAGRAPH.
DISPLAY 'Edsger who now?'
GO TO SOME-OTHER-PARAGRAPH.
|
from goto import goto, label
label .start
for i in range(1, 4):
print i
if i == 2:
try:
output = message
except NameError:
print "Oops - forgot to define 'message'! Start again."
message = "Hello world"
goto .start
print output, "\n"
|
Produce a language-to-language conversion: from COBOL to Python, same semantics. | IDENTIFICATION DIVISION.
PROGRAM-ID. JUMPS-PROGRAM.
* Nobody writes like this, of course; but...
PROCEDURE DIVISION.
* You can jump anywhere you like.
START-PARAGRAPH.
GO TO AN-ARBITRARY-PARAGRAPH.
YET-ANOTHER-PARAGRAPH.
ALTER START-PARAGRAPH TO PROCEED TO A-PARAGRAPH-SOMEWHERE.
* That's right, folks: we don't just have GO TOs, we have GO TOs whose
* destinations can be changed at will, from anywhere in the program,
* at run time.
GO TO START-PARAGRAPH.
* But bear in mind: once you get there, the GO TO no longer goes to
* where it says it goes to.
A-PARAGRAPH-SOMEWHERE.
DISPLAY 'Never heard of him.'
STOP RUN.
SOME-OTHER-PARAGRAPH.
* You think that's bad? You ain't seen nothing.
GO TO YET-ANOTHER-PARAGRAPH.
AN-ARBITRARY-PARAGRAPH.
DISPLAY 'Edsger who now?'
GO TO SOME-OTHER-PARAGRAPH.
|
from goto import goto, label
label .start
for i in range(1, 4):
print i
if i == 2:
try:
output = message
except NameError:
print "Oops - forgot to define 'message'! Start again."
message = "Hello world"
goto .start
print output, "\n"
|
Convert this COBOL block to VB, preserving its control flow and logic. | IDENTIFICATION DIVISION.
PROGRAM-ID. JUMPS-PROGRAM.
* Nobody writes like this, of course; but...
PROCEDURE DIVISION.
* You can jump anywhere you like.
START-PARAGRAPH.
GO TO AN-ARBITRARY-PARAGRAPH.
YET-ANOTHER-PARAGRAPH.
ALTER START-PARAGRAPH TO PROCEED TO A-PARAGRAPH-SOMEWHERE.
* That's right, folks: we don't just have GO TOs, we have GO TOs whose
* destinations can be changed at will, from anywhere in the program,
* at run time.
GO TO START-PARAGRAPH.
* But bear in mind: once you get there, the GO TO no longer goes to
* where it says it goes to.
A-PARAGRAPH-SOMEWHERE.
DISPLAY 'Never heard of him.'
STOP RUN.
SOME-OTHER-PARAGRAPH.
* You think that's bad? You ain't seen nothing.
GO TO YET-ANOTHER-PARAGRAPH.
AN-ARBITRARY-PARAGRAPH.
DISPLAY 'Edsger who now?'
GO TO SOME-OTHER-PARAGRAPH.
| Public Sub jump()
Debug.Print "VBA only allows"
GoTo 1
Debug.Print "no global jumps"
1:
Debug.Print "jumps in procedures with GoTo"
Debug.Print "However,"
On 2 GoSub one, two
Debug.Print "named in the list after
Debug.Print "and execution will continue on the next line"
On 1 GoTo one, two
Debug.Print "For On Error, see Exceptions"
one:
Debug.Print "On <n> GoTo let you jump to the n-th label"
Debug.Print "and won
Exit Sub
two:
Debug.Print "On <n> GoSub let you jump to the n-th label": Return
End Sub
|
Convert this COBOL block to VB, preserving its control flow and logic. | IDENTIFICATION DIVISION.
PROGRAM-ID. JUMPS-PROGRAM.
* Nobody writes like this, of course; but...
PROCEDURE DIVISION.
* You can jump anywhere you like.
START-PARAGRAPH.
GO TO AN-ARBITRARY-PARAGRAPH.
YET-ANOTHER-PARAGRAPH.
ALTER START-PARAGRAPH TO PROCEED TO A-PARAGRAPH-SOMEWHERE.
* That's right, folks: we don't just have GO TOs, we have GO TOs whose
* destinations can be changed at will, from anywhere in the program,
* at run time.
GO TO START-PARAGRAPH.
* But bear in mind: once you get there, the GO TO no longer goes to
* where it says it goes to.
A-PARAGRAPH-SOMEWHERE.
DISPLAY 'Never heard of him.'
STOP RUN.
SOME-OTHER-PARAGRAPH.
* You think that's bad? You ain't seen nothing.
GO TO YET-ANOTHER-PARAGRAPH.
AN-ARBITRARY-PARAGRAPH.
DISPLAY 'Edsger who now?'
GO TO SOME-OTHER-PARAGRAPH.
| Public Sub jump()
Debug.Print "VBA only allows"
GoTo 1
Debug.Print "no global jumps"
1:
Debug.Print "jumps in procedures with GoTo"
Debug.Print "However,"
On 2 GoSub one, two
Debug.Print "named in the list after
Debug.Print "and execution will continue on the next line"
On 1 GoTo one, two
Debug.Print "For On Error, see Exceptions"
one:
Debug.Print "On <n> GoTo let you jump to the n-th label"
Debug.Print "and won
Exit Sub
two:
Debug.Print "On <n> GoSub let you jump to the n-th label": Return
End Sub
|
Port the provided COBOL code into Go while preserving the original functionality. | IDENTIFICATION DIVISION.
PROGRAM-ID. JUMPS-PROGRAM.
* Nobody writes like this, of course; but...
PROCEDURE DIVISION.
* You can jump anywhere you like.
START-PARAGRAPH.
GO TO AN-ARBITRARY-PARAGRAPH.
YET-ANOTHER-PARAGRAPH.
ALTER START-PARAGRAPH TO PROCEED TO A-PARAGRAPH-SOMEWHERE.
* That's right, folks: we don't just have GO TOs, we have GO TOs whose
* destinations can be changed at will, from anywhere in the program,
* at run time.
GO TO START-PARAGRAPH.
* But bear in mind: once you get there, the GO TO no longer goes to
* where it says it goes to.
A-PARAGRAPH-SOMEWHERE.
DISPLAY 'Never heard of him.'
STOP RUN.
SOME-OTHER-PARAGRAPH.
* You think that's bad? You ain't seen nothing.
GO TO YET-ANOTHER-PARAGRAPH.
AN-ARBITRARY-PARAGRAPH.
DISPLAY 'Edsger who now?'
GO TO SOME-OTHER-PARAGRAPH.
| package main
import "fmt"
func main() {
outer:
for i := 0; i < 4; i++ {
for j := 0; j < 4; j++ {
if i + j == 4 { continue outer }
if i + j == 5 { break outer }
fmt.Println(i + j)
}
}
k := 3
if k == 3 { goto later }
fmt.Println(k)
later:
k++
fmt.Println(k)
}
|
Generate an equivalent Go version of this COBOL code. | IDENTIFICATION DIVISION.
PROGRAM-ID. JUMPS-PROGRAM.
* Nobody writes like this, of course; but...
PROCEDURE DIVISION.
* You can jump anywhere you like.
START-PARAGRAPH.
GO TO AN-ARBITRARY-PARAGRAPH.
YET-ANOTHER-PARAGRAPH.
ALTER START-PARAGRAPH TO PROCEED TO A-PARAGRAPH-SOMEWHERE.
* That's right, folks: we don't just have GO TOs, we have GO TOs whose
* destinations can be changed at will, from anywhere in the program,
* at run time.
GO TO START-PARAGRAPH.
* But bear in mind: once you get there, the GO TO no longer goes to
* where it says it goes to.
A-PARAGRAPH-SOMEWHERE.
DISPLAY 'Never heard of him.'
STOP RUN.
SOME-OTHER-PARAGRAPH.
* You think that's bad? You ain't seen nothing.
GO TO YET-ANOTHER-PARAGRAPH.
AN-ARBITRARY-PARAGRAPH.
DISPLAY 'Edsger who now?'
GO TO SOME-OTHER-PARAGRAPH.
| package main
import "fmt"
func main() {
outer:
for i := 0; i < 4; i++ {
for j := 0; j < 4; j++ {
if i + j == 4 { continue outer }
if i + j == 5 { break outer }
fmt.Println(i + j)
}
}
k := 3
if k == 3 { goto later }
fmt.Println(k)
later:
k++
fmt.Println(k)
}
|
Change the following REXX code into C without altering its purpose. |
say 'starting...'
signal aJump
say 'this statement is never executed.'
aJump: say 'and here we are at aJump.'
do j=1 to 10
say 'j=' j
if j==7 then signal bJump
end
bJump: say 'and here we are at bJump.'
signal cJump
say 'this statement is never executed.'
do k=1 to 10
say 'k=' k
cJump: say 'and here we are at cJump.'
exit
end
| if (x > 0) goto positive;
else goto negative;
positive:
printf("pos\n"); goto both;
negative:
printf("neg\n");
both:
...
|
Change the following REXX code into C without altering its purpose. |
say 'starting...'
signal aJump
say 'this statement is never executed.'
aJump: say 'and here we are at aJump.'
do j=1 to 10
say 'j=' j
if j==7 then signal bJump
end
bJump: say 'and here we are at bJump.'
signal cJump
say 'this statement is never executed.'
do k=1 to 10
say 'k=' k
cJump: say 'and here we are at cJump.'
exit
end
| if (x > 0) goto positive;
else goto negative;
positive:
printf("pos\n"); goto both;
negative:
printf("neg\n");
both:
...
|
Can you help me rewrite this code in C# instead of REXX, keeping it the same logically? |
say 'starting...'
signal aJump
say 'this statement is never executed.'
aJump: say 'and here we are at aJump.'
do j=1 to 10
say 'j=' j
if j==7 then signal bJump
end
bJump: say 'and here we are at bJump.'
signal cJump
say 'this statement is never executed.'
do k=1 to 10
say 'k=' k
cJump: say 'and here we are at cJump.'
exit
end
| if (x > 0) goto positive;
else goto negative;
positive:
Console.WriteLine("pos\n"); goto both;
negative:
Console.WriteLine("neg\n");
both:
...
|
Change the following REXX code into C# without altering its purpose. |
say 'starting...'
signal aJump
say 'this statement is never executed.'
aJump: say 'and here we are at aJump.'
do j=1 to 10
say 'j=' j
if j==7 then signal bJump
end
bJump: say 'and here we are at bJump.'
signal cJump
say 'this statement is never executed.'
do k=1 to 10
say 'k=' k
cJump: say 'and here we are at cJump.'
exit
end
| if (x > 0) goto positive;
else goto negative;
positive:
Console.WriteLine("pos\n"); goto both;
negative:
Console.WriteLine("neg\n");
both:
...
|
Rewrite this program in C++ while keeping its functionality equivalent to the REXX version. |
say 'starting...'
signal aJump
say 'this statement is never executed.'
aJump: say 'and here we are at aJump.'
do j=1 to 10
say 'j=' j
if j==7 then signal bJump
end
bJump: say 'and here we are at bJump.'
signal cJump
say 'this statement is never executed.'
do k=1 to 10
say 'k=' k
cJump: say 'and here we are at cJump.'
exit
end
| #include <iostream>
#include <utility>
using namespace std;
int main(void)
{
cout << "Find a solution to i = 2 * j - 7\n";
pair<int, int> answer;
for(int i = 0; true; i++)
{
for(int j = 0; j < i; j++)
{
if( i == 2 * j - 7)
{
answer = make_pair(i, j);
goto loopexit;
}
}
}
loopexit:
cout << answer.first << " = 2 * " << answer.second << " - 7\n\n";
goto spagetti;
int k;
k = 9;
spagetti:
cout << "k = " << k << "\n";
}
|
Produce a language-to-language conversion: from REXX to C++, same semantics. |
say 'starting...'
signal aJump
say 'this statement is never executed.'
aJump: say 'and here we are at aJump.'
do j=1 to 10
say 'j=' j
if j==7 then signal bJump
end
bJump: say 'and here we are at bJump.'
signal cJump
say 'this statement is never executed.'
do k=1 to 10
say 'k=' k
cJump: say 'and here we are at cJump.'
exit
end
| #include <iostream>
#include <utility>
using namespace std;
int main(void)
{
cout << "Find a solution to i = 2 * j - 7\n";
pair<int, int> answer;
for(int i = 0; true; i++)
{
for(int j = 0; j < i; j++)
{
if( i == 2 * j - 7)
{
answer = make_pair(i, j);
goto loopexit;
}
}
}
loopexit:
cout << answer.first << " = 2 * " << answer.second << " - 7\n\n";
goto spagetti;
int k;
k = 9;
spagetti:
cout << "k = " << k << "\n";
}
|
Rewrite this program in Java while keeping its functionality equivalent to the REXX version. |
say 'starting...'
signal aJump
say 'this statement is never executed.'
aJump: say 'and here we are at aJump.'
do j=1 to 10
say 'j=' j
if j==7 then signal bJump
end
bJump: say 'and here we are at bJump.'
signal cJump
say 'this statement is never executed.'
do k=1 to 10
say 'k=' k
cJump: say 'and here we are at cJump.'
exit
end
| loop1: while (x != 0) {
loop2: for (int i = 0; i < 10; i++) {
loop3: do {
if () {
continue loop1;
}
if () {
break loop2;
}
} while (y < 10);
}
}
|
Maintain the same structure and functionality when rewriting this code in Java. |
say 'starting...'
signal aJump
say 'this statement is never executed.'
aJump: say 'and here we are at aJump.'
do j=1 to 10
say 'j=' j
if j==7 then signal bJump
end
bJump: say 'and here we are at bJump.'
signal cJump
say 'this statement is never executed.'
do k=1 to 10
say 'k=' k
cJump: say 'and here we are at cJump.'
exit
end
| loop1: while (x != 0) {
loop2: for (int i = 0; i < 10; i++) {
loop3: do {
if () {
continue loop1;
}
if () {
break loop2;
}
} while (y < 10);
}
}
|
Rewrite the snippet below in Python so it works the same as the original REXX code. |
say 'starting...'
signal aJump
say 'this statement is never executed.'
aJump: say 'and here we are at aJump.'
do j=1 to 10
say 'j=' j
if j==7 then signal bJump
end
bJump: say 'and here we are at bJump.'
signal cJump
say 'this statement is never executed.'
do k=1 to 10
say 'k=' k
cJump: say 'and here we are at cJump.'
exit
end
|
from goto import goto, label
label .start
for i in range(1, 4):
print i
if i == 2:
try:
output = message
except NameError:
print "Oops - forgot to define 'message'! Start again."
message = "Hello world"
goto .start
print output, "\n"
|
Port the provided REXX code into Python while preserving the original functionality. |
say 'starting...'
signal aJump
say 'this statement is never executed.'
aJump: say 'and here we are at aJump.'
do j=1 to 10
say 'j=' j
if j==7 then signal bJump
end
bJump: say 'and here we are at bJump.'
signal cJump
say 'this statement is never executed.'
do k=1 to 10
say 'k=' k
cJump: say 'and here we are at cJump.'
exit
end
|
from goto import goto, label
label .start
for i in range(1, 4):
print i
if i == 2:
try:
output = message
except NameError:
print "Oops - forgot to define 'message'! Start again."
message = "Hello world"
goto .start
print output, "\n"
|
Port the following code from REXX to VB with equivalent syntax and logic. |
say 'starting...'
signal aJump
say 'this statement is never executed.'
aJump: say 'and here we are at aJump.'
do j=1 to 10
say 'j=' j
if j==7 then signal bJump
end
bJump: say 'and here we are at bJump.'
signal cJump
say 'this statement is never executed.'
do k=1 to 10
say 'k=' k
cJump: say 'and here we are at cJump.'
exit
end
| Public Sub jump()
Debug.Print "VBA only allows"
GoTo 1
Debug.Print "no global jumps"
1:
Debug.Print "jumps in procedures with GoTo"
Debug.Print "However,"
On 2 GoSub one, two
Debug.Print "named in the list after
Debug.Print "and execution will continue on the next line"
On 1 GoTo one, two
Debug.Print "For On Error, see Exceptions"
one:
Debug.Print "On <n> GoTo let you jump to the n-th label"
Debug.Print "and won
Exit Sub
two:
Debug.Print "On <n> GoSub let you jump to the n-th label": Return
End Sub
|
Translate the given REXX code snippet into VB without altering its behavior. |
say 'starting...'
signal aJump
say 'this statement is never executed.'
aJump: say 'and here we are at aJump.'
do j=1 to 10
say 'j=' j
if j==7 then signal bJump
end
bJump: say 'and here we are at bJump.'
signal cJump
say 'this statement is never executed.'
do k=1 to 10
say 'k=' k
cJump: say 'and here we are at cJump.'
exit
end
| Public Sub jump()
Debug.Print "VBA only allows"
GoTo 1
Debug.Print "no global jumps"
1:
Debug.Print "jumps in procedures with GoTo"
Debug.Print "However,"
On 2 GoSub one, two
Debug.Print "named in the list after
Debug.Print "and execution will continue on the next line"
On 1 GoTo one, two
Debug.Print "For On Error, see Exceptions"
one:
Debug.Print "On <n> GoTo let you jump to the n-th label"
Debug.Print "and won
Exit Sub
two:
Debug.Print "On <n> GoSub let you jump to the n-th label": Return
End Sub
|
Transform the following REXX implementation into Go, maintaining the same output and logic. |
say 'starting...'
signal aJump
say 'this statement is never executed.'
aJump: say 'and here we are at aJump.'
do j=1 to 10
say 'j=' j
if j==7 then signal bJump
end
bJump: say 'and here we are at bJump.'
signal cJump
say 'this statement is never executed.'
do k=1 to 10
say 'k=' k
cJump: say 'and here we are at cJump.'
exit
end
| package main
import "fmt"
func main() {
outer:
for i := 0; i < 4; i++ {
for j := 0; j < 4; j++ {
if i + j == 4 { continue outer }
if i + j == 5 { break outer }
fmt.Println(i + j)
}
}
k := 3
if k == 3 { goto later }
fmt.Println(k)
later:
k++
fmt.Println(k)
}
|
Keep all operations the same but rewrite the snippet in Go. |
say 'starting...'
signal aJump
say 'this statement is never executed.'
aJump: say 'and here we are at aJump.'
do j=1 to 10
say 'j=' j
if j==7 then signal bJump
end
bJump: say 'and here we are at bJump.'
signal cJump
say 'this statement is never executed.'
do k=1 to 10
say 'k=' k
cJump: say 'and here we are at cJump.'
exit
end
| package main
import "fmt"
func main() {
outer:
for i := 0; i < 4; i++ {
for j := 0; j < 4; j++ {
if i + j == 4 { continue outer }
if i + j == 5 { break outer }
fmt.Println(i + j)
}
}
k := 3
if k == 3 { goto later }
fmt.Println(k)
later:
k++
fmt.Println(k)
}
|
Write the same code in C as shown below in Ruby. | require 'continuation' unless defined? Continuation
if a = callcc { |c| [c, 1] }
c, i = a
c[nil] if i > 100
case 0
when i % 3
print "Fizz"
case 0
when i % 5
print "Buzz"
end
when i % 5
print "Buzz"
else
print i
end
puts
c[c, i + 1]
end
| if (x > 0) goto positive;
else goto negative;
positive:
printf("pos\n"); goto both;
negative:
printf("neg\n");
both:
...
|
Rewrite this program in C while keeping its functionality equivalent to the Ruby version. | require 'continuation' unless defined? Continuation
if a = callcc { |c| [c, 1] }
c, i = a
c[nil] if i > 100
case 0
when i % 3
print "Fizz"
case 0
when i % 5
print "Buzz"
end
when i % 5
print "Buzz"
else
print i
end
puts
c[c, i + 1]
end
| if (x > 0) goto positive;
else goto negative;
positive:
printf("pos\n"); goto both;
negative:
printf("neg\n");
both:
...
|
Generate an equivalent C# version of this Ruby code. | require 'continuation' unless defined? Continuation
if a = callcc { |c| [c, 1] }
c, i = a
c[nil] if i > 100
case 0
when i % 3
print "Fizz"
case 0
when i % 5
print "Buzz"
end
when i % 5
print "Buzz"
else
print i
end
puts
c[c, i + 1]
end
| if (x > 0) goto positive;
else goto negative;
positive:
Console.WriteLine("pos\n"); goto both;
negative:
Console.WriteLine("neg\n");
both:
...
|
Translate the given Ruby code snippet into C# without altering its behavior. | require 'continuation' unless defined? Continuation
if a = callcc { |c| [c, 1] }
c, i = a
c[nil] if i > 100
case 0
when i % 3
print "Fizz"
case 0
when i % 5
print "Buzz"
end
when i % 5
print "Buzz"
else
print i
end
puts
c[c, i + 1]
end
| if (x > 0) goto positive;
else goto negative;
positive:
Console.WriteLine("pos\n"); goto both;
negative:
Console.WriteLine("neg\n");
both:
...
|
Produce a language-to-language conversion: from Ruby to C++, same semantics. | require 'continuation' unless defined? Continuation
if a = callcc { |c| [c, 1] }
c, i = a
c[nil] if i > 100
case 0
when i % 3
print "Fizz"
case 0
when i % 5
print "Buzz"
end
when i % 5
print "Buzz"
else
print i
end
puts
c[c, i + 1]
end
| #include <iostream>
#include <utility>
using namespace std;
int main(void)
{
cout << "Find a solution to i = 2 * j - 7\n";
pair<int, int> answer;
for(int i = 0; true; i++)
{
for(int j = 0; j < i; j++)
{
if( i == 2 * j - 7)
{
answer = make_pair(i, j);
goto loopexit;
}
}
}
loopexit:
cout << answer.first << " = 2 * " << answer.second << " - 7\n\n";
goto spagetti;
int k;
k = 9;
spagetti:
cout << "k = " << k << "\n";
}
|
Change the following Ruby code into C++ without altering its purpose. | require 'continuation' unless defined? Continuation
if a = callcc { |c| [c, 1] }
c, i = a
c[nil] if i > 100
case 0
when i % 3
print "Fizz"
case 0
when i % 5
print "Buzz"
end
when i % 5
print "Buzz"
else
print i
end
puts
c[c, i + 1]
end
| #include <iostream>
#include <utility>
using namespace std;
int main(void)
{
cout << "Find a solution to i = 2 * j - 7\n";
pair<int, int> answer;
for(int i = 0; true; i++)
{
for(int j = 0; j < i; j++)
{
if( i == 2 * j - 7)
{
answer = make_pair(i, j);
goto loopexit;
}
}
}
loopexit:
cout << answer.first << " = 2 * " << answer.second << " - 7\n\n";
goto spagetti;
int k;
k = 9;
spagetti:
cout << "k = " << k << "\n";
}
|
Translate the given Ruby code snippet into Java without altering its behavior. | require 'continuation' unless defined? Continuation
if a = callcc { |c| [c, 1] }
c, i = a
c[nil] if i > 100
case 0
when i % 3
print "Fizz"
case 0
when i % 5
print "Buzz"
end
when i % 5
print "Buzz"
else
print i
end
puts
c[c, i + 1]
end
| loop1: while (x != 0) {
loop2: for (int i = 0; i < 10; i++) {
loop3: do {
if () {
continue loop1;
}
if () {
break loop2;
}
} while (y < 10);
}
}
|
Rewrite this program in Java while keeping its functionality equivalent to the Ruby version. | require 'continuation' unless defined? Continuation
if a = callcc { |c| [c, 1] }
c, i = a
c[nil] if i > 100
case 0
when i % 3
print "Fizz"
case 0
when i % 5
print "Buzz"
end
when i % 5
print "Buzz"
else
print i
end
puts
c[c, i + 1]
end
| loop1: while (x != 0) {
loop2: for (int i = 0; i < 10; i++) {
loop3: do {
if () {
continue loop1;
}
if () {
break loop2;
}
} while (y < 10);
}
}
|
Change the programming language of this snippet from Ruby to Python without modifying what it does. | require 'continuation' unless defined? Continuation
if a = callcc { |c| [c, 1] }
c, i = a
c[nil] if i > 100
case 0
when i % 3
print "Fizz"
case 0
when i % 5
print "Buzz"
end
when i % 5
print "Buzz"
else
print i
end
puts
c[c, i + 1]
end
|
from goto import goto, label
label .start
for i in range(1, 4):
print i
if i == 2:
try:
output = message
except NameError:
print "Oops - forgot to define 'message'! Start again."
message = "Hello world"
goto .start
print output, "\n"
|
Produce a functionally identical Python code for the snippet given in Ruby. | require 'continuation' unless defined? Continuation
if a = callcc { |c| [c, 1] }
c, i = a
c[nil] if i > 100
case 0
when i % 3
print "Fizz"
case 0
when i % 5
print "Buzz"
end
when i % 5
print "Buzz"
else
print i
end
puts
c[c, i + 1]
end
|
from goto import goto, label
label .start
for i in range(1, 4):
print i
if i == 2:
try:
output = message
except NameError:
print "Oops - forgot to define 'message'! Start again."
message = "Hello world"
goto .start
print output, "\n"
|
Translate this program into VB but keep the logic exactly as in Ruby. | require 'continuation' unless defined? Continuation
if a = callcc { |c| [c, 1] }
c, i = a
c[nil] if i > 100
case 0
when i % 3
print "Fizz"
case 0
when i % 5
print "Buzz"
end
when i % 5
print "Buzz"
else
print i
end
puts
c[c, i + 1]
end
| Public Sub jump()
Debug.Print "VBA only allows"
GoTo 1
Debug.Print "no global jumps"
1:
Debug.Print "jumps in procedures with GoTo"
Debug.Print "However,"
On 2 GoSub one, two
Debug.Print "named in the list after
Debug.Print "and execution will continue on the next line"
On 1 GoTo one, two
Debug.Print "For On Error, see Exceptions"
one:
Debug.Print "On <n> GoTo let you jump to the n-th label"
Debug.Print "and won
Exit Sub
two:
Debug.Print "On <n> GoSub let you jump to the n-th label": Return
End Sub
|
Convert this Ruby block to VB, preserving its control flow and logic. | require 'continuation' unless defined? Continuation
if a = callcc { |c| [c, 1] }
c, i = a
c[nil] if i > 100
case 0
when i % 3
print "Fizz"
case 0
when i % 5
print "Buzz"
end
when i % 5
print "Buzz"
else
print i
end
puts
c[c, i + 1]
end
| Public Sub jump()
Debug.Print "VBA only allows"
GoTo 1
Debug.Print "no global jumps"
1:
Debug.Print "jumps in procedures with GoTo"
Debug.Print "However,"
On 2 GoSub one, two
Debug.Print "named in the list after
Debug.Print "and execution will continue on the next line"
On 1 GoTo one, two
Debug.Print "For On Error, see Exceptions"
one:
Debug.Print "On <n> GoTo let you jump to the n-th label"
Debug.Print "and won
Exit Sub
two:
Debug.Print "On <n> GoSub let you jump to the n-th label": Return
End Sub
|
Change the following Ruby code into Go without altering its purpose. | require 'continuation' unless defined? Continuation
if a = callcc { |c| [c, 1] }
c, i = a
c[nil] if i > 100
case 0
when i % 3
print "Fizz"
case 0
when i % 5
print "Buzz"
end
when i % 5
print "Buzz"
else
print i
end
puts
c[c, i + 1]
end
| package main
import "fmt"
func main() {
outer:
for i := 0; i < 4; i++ {
for j := 0; j < 4; j++ {
if i + j == 4 { continue outer }
if i + j == 5 { break outer }
fmt.Println(i + j)
}
}
k := 3
if k == 3 { goto later }
fmt.Println(k)
later:
k++
fmt.Println(k)
}
|
Keep all operations the same but rewrite the snippet in Go. | require 'continuation' unless defined? Continuation
if a = callcc { |c| [c, 1] }
c, i = a
c[nil] if i > 100
case 0
when i % 3
print "Fizz"
case 0
when i % 5
print "Buzz"
end
when i % 5
print "Buzz"
else
print i
end
puts
c[c, i + 1]
end
| package main
import "fmt"
func main() {
outer:
for i := 0; i < 4; i++ {
for j := 0; j < 4; j++ {
if i + j == 4 { continue outer }
if i + j == 5 { break outer }
fmt.Println(i + j)
}
}
k := 3
if k == 3 { goto later }
fmt.Println(k)
later:
k++
fmt.Println(k)
}
|
Please provide an equivalent version of this Scala code in C. |
fun main(args: Array<String>) {
intArrayOf(4, 5, 6).forEach lambda@ {
if (it == 5) return@lambda
println(it)
}
println()
loop@ for (i in 0 .. 3) {
for (j in 0 .. 3) {
if (i + j == 4) continue@loop
if (i + j == 5) break@loop
println(i + j)
}
}
}
| if (x > 0) goto positive;
else goto negative;
positive:
printf("pos\n"); goto both;
negative:
printf("neg\n");
both:
...
|
Port the following code from Scala to C with equivalent syntax and logic. |
fun main(args: Array<String>) {
intArrayOf(4, 5, 6).forEach lambda@ {
if (it == 5) return@lambda
println(it)
}
println()
loop@ for (i in 0 .. 3) {
for (j in 0 .. 3) {
if (i + j == 4) continue@loop
if (i + j == 5) break@loop
println(i + j)
}
}
}
| if (x > 0) goto positive;
else goto negative;
positive:
printf("pos\n"); goto both;
negative:
printf("neg\n");
both:
...
|
Keep all operations the same but rewrite the snippet in C#. |
fun main(args: Array<String>) {
intArrayOf(4, 5, 6).forEach lambda@ {
if (it == 5) return@lambda
println(it)
}
println()
loop@ for (i in 0 .. 3) {
for (j in 0 .. 3) {
if (i + j == 4) continue@loop
if (i + j == 5) break@loop
println(i + j)
}
}
}
| if (x > 0) goto positive;
else goto negative;
positive:
Console.WriteLine("pos\n"); goto both;
negative:
Console.WriteLine("neg\n");
both:
...
|
Keep all operations the same but rewrite the snippet in C#. |
fun main(args: Array<String>) {
intArrayOf(4, 5, 6).forEach lambda@ {
if (it == 5) return@lambda
println(it)
}
println()
loop@ for (i in 0 .. 3) {
for (j in 0 .. 3) {
if (i + j == 4) continue@loop
if (i + j == 5) break@loop
println(i + j)
}
}
}
| if (x > 0) goto positive;
else goto negative;
positive:
Console.WriteLine("pos\n"); goto both;
negative:
Console.WriteLine("neg\n");
both:
...
|
Preserve the algorithm and functionality while converting the code from Scala to C++. |
fun main(args: Array<String>) {
intArrayOf(4, 5, 6).forEach lambda@ {
if (it == 5) return@lambda
println(it)
}
println()
loop@ for (i in 0 .. 3) {
for (j in 0 .. 3) {
if (i + j == 4) continue@loop
if (i + j == 5) break@loop
println(i + j)
}
}
}
| #include <iostream>
#include <utility>
using namespace std;
int main(void)
{
cout << "Find a solution to i = 2 * j - 7\n";
pair<int, int> answer;
for(int i = 0; true; i++)
{
for(int j = 0; j < i; j++)
{
if( i == 2 * j - 7)
{
answer = make_pair(i, j);
goto loopexit;
}
}
}
loopexit:
cout << answer.first << " = 2 * " << answer.second << " - 7\n\n";
goto spagetti;
int k;
k = 9;
spagetti:
cout << "k = " << k << "\n";
}
|
Change the programming language of this snippet from Scala to C++ without modifying what it does. |
fun main(args: Array<String>) {
intArrayOf(4, 5, 6).forEach lambda@ {
if (it == 5) return@lambda
println(it)
}
println()
loop@ for (i in 0 .. 3) {
for (j in 0 .. 3) {
if (i + j == 4) continue@loop
if (i + j == 5) break@loop
println(i + j)
}
}
}
| #include <iostream>
#include <utility>
using namespace std;
int main(void)
{
cout << "Find a solution to i = 2 * j - 7\n";
pair<int, int> answer;
for(int i = 0; true; i++)
{
for(int j = 0; j < i; j++)
{
if( i == 2 * j - 7)
{
answer = make_pair(i, j);
goto loopexit;
}
}
}
loopexit:
cout << answer.first << " = 2 * " << answer.second << " - 7\n\n";
goto spagetti;
int k;
k = 9;
spagetti:
cout << "k = " << k << "\n";
}
|
Port the following code from Scala to Java with equivalent syntax and logic. |
fun main(args: Array<String>) {
intArrayOf(4, 5, 6).forEach lambda@ {
if (it == 5) return@lambda
println(it)
}
println()
loop@ for (i in 0 .. 3) {
for (j in 0 .. 3) {
if (i + j == 4) continue@loop
if (i + j == 5) break@loop
println(i + j)
}
}
}
| loop1: while (x != 0) {
loop2: for (int i = 0; i < 10; i++) {
loop3: do {
if () {
continue loop1;
}
if () {
break loop2;
}
} while (y < 10);
}
}
|
Translate this program into Java but keep the logic exactly as in Scala. |
fun main(args: Array<String>) {
intArrayOf(4, 5, 6).forEach lambda@ {
if (it == 5) return@lambda
println(it)
}
println()
loop@ for (i in 0 .. 3) {
for (j in 0 .. 3) {
if (i + j == 4) continue@loop
if (i + j == 5) break@loop
println(i + j)
}
}
}
| loop1: while (x != 0) {
loop2: for (int i = 0; i < 10; i++) {
loop3: do {
if () {
continue loop1;
}
if () {
break loop2;
}
} while (y < 10);
}
}
|
Translate the given Scala code snippet into Python without altering its behavior. |
fun main(args: Array<String>) {
intArrayOf(4, 5, 6).forEach lambda@ {
if (it == 5) return@lambda
println(it)
}
println()
loop@ for (i in 0 .. 3) {
for (j in 0 .. 3) {
if (i + j == 4) continue@loop
if (i + j == 5) break@loop
println(i + j)
}
}
}
|
from goto import goto, label
label .start
for i in range(1, 4):
print i
if i == 2:
try:
output = message
except NameError:
print "Oops - forgot to define 'message'! Start again."
message = "Hello world"
goto .start
print output, "\n"
|
Transform the following Scala implementation into Python, maintaining the same output and logic. |
fun main(args: Array<String>) {
intArrayOf(4, 5, 6).forEach lambda@ {
if (it == 5) return@lambda
println(it)
}
println()
loop@ for (i in 0 .. 3) {
for (j in 0 .. 3) {
if (i + j == 4) continue@loop
if (i + j == 5) break@loop
println(i + j)
}
}
}
|
from goto import goto, label
label .start
for i in range(1, 4):
print i
if i == 2:
try:
output = message
except NameError:
print "Oops - forgot to define 'message'! Start again."
message = "Hello world"
goto .start
print output, "\n"
|
Can you help me rewrite this code in VB instead of Scala, keeping it the same logically? |
fun main(args: Array<String>) {
intArrayOf(4, 5, 6).forEach lambda@ {
if (it == 5) return@lambda
println(it)
}
println()
loop@ for (i in 0 .. 3) {
for (j in 0 .. 3) {
if (i + j == 4) continue@loop
if (i + j == 5) break@loop
println(i + j)
}
}
}
| Public Sub jump()
Debug.Print "VBA only allows"
GoTo 1
Debug.Print "no global jumps"
1:
Debug.Print "jumps in procedures with GoTo"
Debug.Print "However,"
On 2 GoSub one, two
Debug.Print "named in the list after
Debug.Print "and execution will continue on the next line"
On 1 GoTo one, two
Debug.Print "For On Error, see Exceptions"
one:
Debug.Print "On <n> GoTo let you jump to the n-th label"
Debug.Print "and won
Exit Sub
two:
Debug.Print "On <n> GoSub let you jump to the n-th label": Return
End Sub
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.