Instruction stringlengths 45 106 | input_code stringlengths 1 13.7k | output_code stringlengths 1 13.7k |
|---|---|---|
Can you help me rewrite this code in Go instead of MATLAB, keeping it the same logically? | >> get(0,'RecursionLimit')
ans =
500
>> set(0,'RecursionLimit',2500)
>> get(0,'RecursionLimit')
ans =
2500
| package main
import (
"flag"
"fmt"
"runtime/debug"
)
func main() {
stack := flag.Int("stack", 0, "maximum per goroutine stack size or 0 for the default")
flag.Parse()
if *stack > 0 {
debug.SetMaxStack(*stack)
}
r(1)
}
func r(l int) {
if l%1000 == 0 {
fmt.Println(l)
}
r(l + 1)
}
|
Produce a functionally identical Go code for the snippet given in MATLAB. | >> get(0,'RecursionLimit')
ans =
500
>> set(0,'RecursionLimit',2500)
>> get(0,'RecursionLimit')
ans =
2500
| package main
import (
"flag"
"fmt"
"runtime/debug"
)
func main() {
stack := flag.Int("stack", 0, "maximum per goroutine stack size or 0 for the default")
flag.Parse()
if *stack > 0 {
debug.SetMaxStack(*stack)
}
r(1)
}
func r(l int) {
if l%1000 == 0 {
fmt.Println(l)
}
r(l + 1)
}
|
Convert this Nim block to C, preserving its control flow and logic. | proc recurse(i: int): int =
echo i
recurse(i+1)
echo recurse(0)
| #include <stdio.h>
void recurse(unsigned int i)
{
printf("%d\n", i);
recurse(i+1);
}
int main()
{
recurse(0);
return 0;
}
|
Port the provided Nim code into C while preserving the original functionality. | proc recurse(i: int): int =
echo i
recurse(i+1)
echo recurse(0)
| #include <stdio.h>
void recurse(unsigned int i)
{
printf("%d\n", i);
recurse(i+1);
}
int main()
{
recurse(0);
return 0;
}
|
Convert the following code from Nim to C#, ensuring the logic remains intact. | proc recurse(i: int): int =
echo i
recurse(i+1)
echo recurse(0)
| using System;
class RecursionLimit
{
static void Main(string[] args)
{
Recur(0);
}
private static void Recur(int i)
{
Console.WriteLine(i);
Recur(i + 1);
}
}
|
Ensure the translated C# code behaves exactly like the original Nim snippet. | proc recurse(i: int): int =
echo i
recurse(i+1)
echo recurse(0)
| using System;
class RecursionLimit
{
static void Main(string[] args)
{
Recur(0);
}
private static void Recur(int i)
{
Console.WriteLine(i);
Recur(i + 1);
}
}
|
Port the provided Nim code into C++ while preserving the original functionality. | proc recurse(i: int): int =
echo i
recurse(i+1)
echo recurse(0)
| #include <iostream>
void recurse(unsigned int i)
{
std::cout<<i<<"\n";
recurse(i+1);
}
int main()
{
recurse(0);
}
|
Rewrite this program in C++ while keeping its functionality equivalent to the Nim version. | proc recurse(i: int): int =
echo i
recurse(i+1)
echo recurse(0)
| #include <iostream>
void recurse(unsigned int i)
{
std::cout<<i<<"\n";
recurse(i+1);
}
int main()
{
recurse(0);
}
|
Rewrite the snippet below in Java so it works the same as the original Nim code. | proc recurse(i: int): int =
echo i
recurse(i+1)
echo recurse(0)
| public class RecursionTest {
private static void recurse(int i) {
try {
recurse(i+1);
} catch (StackOverflowError e) {
System.out.print("Recursion depth on this system is " + i + ".");
}
}
public static void main(String[] args) {
recurse(0);
}
}
|
Generate a Java translation of this Nim snippet without changing its computational steps. | proc recurse(i: int): int =
echo i
recurse(i+1)
echo recurse(0)
| public class RecursionTest {
private static void recurse(int i) {
try {
recurse(i+1);
} catch (StackOverflowError e) {
System.out.print("Recursion depth on this system is " + i + ".");
}
}
public static void main(String[] args) {
recurse(0);
}
}
|
Transform the following Nim implementation into Python, maintaining the same output and logic. | proc recurse(i: int): int =
echo i
recurse(i+1)
echo recurse(0)
| import sys
print(sys.getrecursionlimit())
|
Produce a functionally identical Python code for the snippet given in Nim. | proc recurse(i: int): int =
echo i
recurse(i+1)
echo recurse(0)
| import sys
print(sys.getrecursionlimit())
|
Convert the following code from Nim to VB, ensuring the logic remains intact. | proc recurse(i: int): int =
echo i
recurse(i+1)
echo recurse(0)
| Option Explicit
Sub Main()
Debug.Print "The limit is : " & Limite_Recursivite(0)
End Sub
Function Limite_Recursivite(Cpt As Long) As Long
Cpt = Cpt + 1
On Error Resume Next
Limite_Recursivite Cpt
On Error GoTo 0
Limite_Recursivite = Cpt
End Function
|
Please provide an equivalent version of this Nim code in VB. | proc recurse(i: int): int =
echo i
recurse(i+1)
echo recurse(0)
| Option Explicit
Sub Main()
Debug.Print "The limit is : " & Limite_Recursivite(0)
End Sub
Function Limite_Recursivite(Cpt As Long) As Long
Cpt = Cpt + 1
On Error Resume Next
Limite_Recursivite Cpt
On Error GoTo 0
Limite_Recursivite = Cpt
End Function
|
Generate an equivalent Go version of this Nim code. | proc recurse(i: int): int =
echo i
recurse(i+1)
echo recurse(0)
| package main
import (
"flag"
"fmt"
"runtime/debug"
)
func main() {
stack := flag.Int("stack", 0, "maximum per goroutine stack size or 0 for the default")
flag.Parse()
if *stack > 0 {
debug.SetMaxStack(*stack)
}
r(1)
}
func r(l int) {
if l%1000 == 0 {
fmt.Println(l)
}
r(l + 1)
}
|
Port the provided Nim code into Go while preserving the original functionality. | proc recurse(i: int): int =
echo i
recurse(i+1)
echo recurse(0)
| package main
import (
"flag"
"fmt"
"runtime/debug"
)
func main() {
stack := flag.Int("stack", 0, "maximum per goroutine stack size or 0 for the default")
flag.Parse()
if *stack > 0 {
debug.SetMaxStack(*stack)
}
r(1)
}
func r(l int) {
if l%1000 == 0 {
fmt.Println(l)
}
r(l + 1)
}
|
Produce a functionally identical C code for the snippet given in OCaml. | # let last = ref 0 ;;
val last : int ref = {contents = 0}
# let rec f i =
last := i;
i + (f (i+1))
;;
val f : int -> int = <fun>
# f 0 ;;
stack overflow during evaluation (looping recursion?).
# !last ;;
- : int = 262067
| #include <stdio.h>
void recurse(unsigned int i)
{
printf("%d\n", i);
recurse(i+1);
}
int main()
{
recurse(0);
return 0;
}
|
Write the same code in C as shown below in OCaml. | # let last = ref 0 ;;
val last : int ref = {contents = 0}
# let rec f i =
last := i;
i + (f (i+1))
;;
val f : int -> int = <fun>
# f 0 ;;
stack overflow during evaluation (looping recursion?).
# !last ;;
- : int = 262067
| #include <stdio.h>
void recurse(unsigned int i)
{
printf("%d\n", i);
recurse(i+1);
}
int main()
{
recurse(0);
return 0;
}
|
Ensure the translated C# code behaves exactly like the original OCaml snippet. | # let last = ref 0 ;;
val last : int ref = {contents = 0}
# let rec f i =
last := i;
i + (f (i+1))
;;
val f : int -> int = <fun>
# f 0 ;;
stack overflow during evaluation (looping recursion?).
# !last ;;
- : int = 262067
| using System;
class RecursionLimit
{
static void Main(string[] args)
{
Recur(0);
}
private static void Recur(int i)
{
Console.WriteLine(i);
Recur(i + 1);
}
}
|
Convert this OCaml snippet to C# and keep its semantics consistent. | # let last = ref 0 ;;
val last : int ref = {contents = 0}
# let rec f i =
last := i;
i + (f (i+1))
;;
val f : int -> int = <fun>
# f 0 ;;
stack overflow during evaluation (looping recursion?).
# !last ;;
- : int = 262067
| using System;
class RecursionLimit
{
static void Main(string[] args)
{
Recur(0);
}
private static void Recur(int i)
{
Console.WriteLine(i);
Recur(i + 1);
}
}
|
Rewrite the snippet below in C++ so it works the same as the original OCaml code. | # let last = ref 0 ;;
val last : int ref = {contents = 0}
# let rec f i =
last := i;
i + (f (i+1))
;;
val f : int -> int = <fun>
# f 0 ;;
stack overflow during evaluation (looping recursion?).
# !last ;;
- : int = 262067
| #include <iostream>
void recurse(unsigned int i)
{
std::cout<<i<<"\n";
recurse(i+1);
}
int main()
{
recurse(0);
}
|
Maintain the same structure and functionality when rewriting this code in C++. | # let last = ref 0 ;;
val last : int ref = {contents = 0}
# let rec f i =
last := i;
i + (f (i+1))
;;
val f : int -> int = <fun>
# f 0 ;;
stack overflow during evaluation (looping recursion?).
# !last ;;
- : int = 262067
| #include <iostream>
void recurse(unsigned int i)
{
std::cout<<i<<"\n";
recurse(i+1);
}
int main()
{
recurse(0);
}
|
Please provide an equivalent version of this OCaml code in Java. | # let last = ref 0 ;;
val last : int ref = {contents = 0}
# let rec f i =
last := i;
i + (f (i+1))
;;
val f : int -> int = <fun>
# f 0 ;;
stack overflow during evaluation (looping recursion?).
# !last ;;
- : int = 262067
| public class RecursionTest {
private static void recurse(int i) {
try {
recurse(i+1);
} catch (StackOverflowError e) {
System.out.print("Recursion depth on this system is " + i + ".");
}
}
public static void main(String[] args) {
recurse(0);
}
}
|
Port the provided OCaml code into Java while preserving the original functionality. | # let last = ref 0 ;;
val last : int ref = {contents = 0}
# let rec f i =
last := i;
i + (f (i+1))
;;
val f : int -> int = <fun>
# f 0 ;;
stack overflow during evaluation (looping recursion?).
# !last ;;
- : int = 262067
| public class RecursionTest {
private static void recurse(int i) {
try {
recurse(i+1);
} catch (StackOverflowError e) {
System.out.print("Recursion depth on this system is " + i + ".");
}
}
public static void main(String[] args) {
recurse(0);
}
}
|
Convert the following code from OCaml to Python, ensuring the logic remains intact. | # let last = ref 0 ;;
val last : int ref = {contents = 0}
# let rec f i =
last := i;
i + (f (i+1))
;;
val f : int -> int = <fun>
# f 0 ;;
stack overflow during evaluation (looping recursion?).
# !last ;;
- : int = 262067
| import sys
print(sys.getrecursionlimit())
|
Write the same algorithm in Python as shown in this OCaml implementation. | # let last = ref 0 ;;
val last : int ref = {contents = 0}
# let rec f i =
last := i;
i + (f (i+1))
;;
val f : int -> int = <fun>
# f 0 ;;
stack overflow during evaluation (looping recursion?).
# !last ;;
- : int = 262067
| import sys
print(sys.getrecursionlimit())
|
Convert this OCaml snippet to VB and keep its semantics consistent. | # let last = ref 0 ;;
val last : int ref = {contents = 0}
# let rec f i =
last := i;
i + (f (i+1))
;;
val f : int -> int = <fun>
# f 0 ;;
stack overflow during evaluation (looping recursion?).
# !last ;;
- : int = 262067
| Option Explicit
Sub Main()
Debug.Print "The limit is : " & Limite_Recursivite(0)
End Sub
Function Limite_Recursivite(Cpt As Long) As Long
Cpt = Cpt + 1
On Error Resume Next
Limite_Recursivite Cpt
On Error GoTo 0
Limite_Recursivite = Cpt
End Function
|
Convert the following code from OCaml to VB, ensuring the logic remains intact. | # let last = ref 0 ;;
val last : int ref = {contents = 0}
# let rec f i =
last := i;
i + (f (i+1))
;;
val f : int -> int = <fun>
# f 0 ;;
stack overflow during evaluation (looping recursion?).
# !last ;;
- : int = 262067
| Option Explicit
Sub Main()
Debug.Print "The limit is : " & Limite_Recursivite(0)
End Sub
Function Limite_Recursivite(Cpt As Long) As Long
Cpt = Cpt + 1
On Error Resume Next
Limite_Recursivite Cpt
On Error GoTo 0
Limite_Recursivite = Cpt
End Function
|
Produce a language-to-language conversion: from OCaml to Go, same semantics. | # let last = ref 0 ;;
val last : int ref = {contents = 0}
# let rec f i =
last := i;
i + (f (i+1))
;;
val f : int -> int = <fun>
# f 0 ;;
stack overflow during evaluation (looping recursion?).
# !last ;;
- : int = 262067
| package main
import (
"flag"
"fmt"
"runtime/debug"
)
func main() {
stack := flag.Int("stack", 0, "maximum per goroutine stack size or 0 for the default")
flag.Parse()
if *stack > 0 {
debug.SetMaxStack(*stack)
}
r(1)
}
func r(l int) {
if l%1000 == 0 {
fmt.Println(l)
}
r(l + 1)
}
|
Rewrite the snippet below in Go so it works the same as the original OCaml code. | # let last = ref 0 ;;
val last : int ref = {contents = 0}
# let rec f i =
last := i;
i + (f (i+1))
;;
val f : int -> int = <fun>
# f 0 ;;
stack overflow during evaluation (looping recursion?).
# !last ;;
- : int = 262067
| package main
import (
"flag"
"fmt"
"runtime/debug"
)
func main() {
stack := flag.Int("stack", 0, "maximum per goroutine stack size or 0 for the default")
flag.Parse()
if *stack > 0 {
debug.SetMaxStack(*stack)
}
r(1)
}
func r(l int) {
if l%1000 == 0 {
fmt.Println(l)
}
r(l + 1)
}
|
Can you help me rewrite this code in C instead of Perl, keeping it the same logically? | my $x = 0;
recurse($x);
sub recurse ($x) {
print ++$x,"\n";
recurse($x);
}
| #include <stdio.h>
void recurse(unsigned int i)
{
printf("%d\n", i);
recurse(i+1);
}
int main()
{
recurse(0);
return 0;
}
|
Write a version of this Perl function in C with identical behavior. | my $x = 0;
recurse($x);
sub recurse ($x) {
print ++$x,"\n";
recurse($x);
}
| #include <stdio.h>
void recurse(unsigned int i)
{
printf("%d\n", i);
recurse(i+1);
}
int main()
{
recurse(0);
return 0;
}
|
Port the following code from Perl to C# with equivalent syntax and logic. | my $x = 0;
recurse($x);
sub recurse ($x) {
print ++$x,"\n";
recurse($x);
}
| using System;
class RecursionLimit
{
static void Main(string[] args)
{
Recur(0);
}
private static void Recur(int i)
{
Console.WriteLine(i);
Recur(i + 1);
}
}
|
Ensure the translated C++ code behaves exactly like the original Perl snippet. | my $x = 0;
recurse($x);
sub recurse ($x) {
print ++$x,"\n";
recurse($x);
}
| #include <iostream>
void recurse(unsigned int i)
{
std::cout<<i<<"\n";
recurse(i+1);
}
int main()
{
recurse(0);
}
|
Preserve the algorithm and functionality while converting the code from Perl to C++. | my $x = 0;
recurse($x);
sub recurse ($x) {
print ++$x,"\n";
recurse($x);
}
| #include <iostream>
void recurse(unsigned int i)
{
std::cout<<i<<"\n";
recurse(i+1);
}
int main()
{
recurse(0);
}
|
Produce a language-to-language conversion: from Perl to Java, same semantics. | my $x = 0;
recurse($x);
sub recurse ($x) {
print ++$x,"\n";
recurse($x);
}
| public class RecursionTest {
private static void recurse(int i) {
try {
recurse(i+1);
} catch (StackOverflowError e) {
System.out.print("Recursion depth on this system is " + i + ".");
}
}
public static void main(String[] args) {
recurse(0);
}
}
|
Write the same algorithm in Java as shown in this Perl implementation. | my $x = 0;
recurse($x);
sub recurse ($x) {
print ++$x,"\n";
recurse($x);
}
| public class RecursionTest {
private static void recurse(int i) {
try {
recurse(i+1);
} catch (StackOverflowError e) {
System.out.print("Recursion depth on this system is " + i + ".");
}
}
public static void main(String[] args) {
recurse(0);
}
}
|
Change the following Perl code into Python without altering its purpose. | my $x = 0;
recurse($x);
sub recurse ($x) {
print ++$x,"\n";
recurse($x);
}
| import sys
print(sys.getrecursionlimit())
|
Write a version of this Perl function in Python with identical behavior. | my $x = 0;
recurse($x);
sub recurse ($x) {
print ++$x,"\n";
recurse($x);
}
| import sys
print(sys.getrecursionlimit())
|
Translate this program into VB but keep the logic exactly as in Perl. | my $x = 0;
recurse($x);
sub recurse ($x) {
print ++$x,"\n";
recurse($x);
}
| Option Explicit
Sub Main()
Debug.Print "The limit is : " & Limite_Recursivite(0)
End Sub
Function Limite_Recursivite(Cpt As Long) As Long
Cpt = Cpt + 1
On Error Resume Next
Limite_Recursivite Cpt
On Error GoTo 0
Limite_Recursivite = Cpt
End Function
|
Produce a language-to-language conversion: from Perl to VB, same semantics. | my $x = 0;
recurse($x);
sub recurse ($x) {
print ++$x,"\n";
recurse($x);
}
| Option Explicit
Sub Main()
Debug.Print "The limit is : " & Limite_Recursivite(0)
End Sub
Function Limite_Recursivite(Cpt As Long) As Long
Cpt = Cpt + 1
On Error Resume Next
Limite_Recursivite Cpt
On Error GoTo 0
Limite_Recursivite = Cpt
End Function
|
Please provide an equivalent version of this Perl code in Go. | my $x = 0;
recurse($x);
sub recurse ($x) {
print ++$x,"\n";
recurse($x);
}
| package main
import (
"flag"
"fmt"
"runtime/debug"
)
func main() {
stack := flag.Int("stack", 0, "maximum per goroutine stack size or 0 for the default")
flag.Parse()
if *stack > 0 {
debug.SetMaxStack(*stack)
}
r(1)
}
func r(l int) {
if l%1000 == 0 {
fmt.Println(l)
}
r(l + 1)
}
|
Port the following code from Perl to Go with equivalent syntax and logic. | my $x = 0;
recurse($x);
sub recurse ($x) {
print ++$x,"\n";
recurse($x);
}
| package main
import (
"flag"
"fmt"
"runtime/debug"
)
func main() {
stack := flag.Int("stack", 0, "maximum per goroutine stack size or 0 for the default")
flag.Parse()
if *stack > 0 {
debug.SetMaxStack(*stack)
}
r(1)
}
func r(l int) {
if l%1000 == 0 {
fmt.Println(l)
}
r(l + 1)
}
|
Translate the given PowerShell code snippet into C without altering its behavior. | function TestDepth ( $N )
{
$N
TestDepth ( $N + 1 )
}
try
{
TestDepth 1 | ForEach { $Depth = $_ }
}
catch
{
"Exception message: " + $_.Exception.Message
}
"Last level before error: " + $Depth
| #include <stdio.h>
void recurse(unsigned int i)
{
printf("%d\n", i);
recurse(i+1);
}
int main()
{
recurse(0);
return 0;
}
|
Rewrite this program in C while keeping its functionality equivalent to the PowerShell version. | function TestDepth ( $N )
{
$N
TestDepth ( $N + 1 )
}
try
{
TestDepth 1 | ForEach { $Depth = $_ }
}
catch
{
"Exception message: " + $_.Exception.Message
}
"Last level before error: " + $Depth
| #include <stdio.h>
void recurse(unsigned int i)
{
printf("%d\n", i);
recurse(i+1);
}
int main()
{
recurse(0);
return 0;
}
|
Translate the given PowerShell code snippet into C# without altering its behavior. | function TestDepth ( $N )
{
$N
TestDepth ( $N + 1 )
}
try
{
TestDepth 1 | ForEach { $Depth = $_ }
}
catch
{
"Exception message: " + $_.Exception.Message
}
"Last level before error: " + $Depth
| using System;
class RecursionLimit
{
static void Main(string[] args)
{
Recur(0);
}
private static void Recur(int i)
{
Console.WriteLine(i);
Recur(i + 1);
}
}
|
Convert the following code from PowerShell to C#, ensuring the logic remains intact. | function TestDepth ( $N )
{
$N
TestDepth ( $N + 1 )
}
try
{
TestDepth 1 | ForEach { $Depth = $_ }
}
catch
{
"Exception message: " + $_.Exception.Message
}
"Last level before error: " + $Depth
| using System;
class RecursionLimit
{
static void Main(string[] args)
{
Recur(0);
}
private static void Recur(int i)
{
Console.WriteLine(i);
Recur(i + 1);
}
}
|
Port the following code from PowerShell to C++ with equivalent syntax and logic. | function TestDepth ( $N )
{
$N
TestDepth ( $N + 1 )
}
try
{
TestDepth 1 | ForEach { $Depth = $_ }
}
catch
{
"Exception message: " + $_.Exception.Message
}
"Last level before error: " + $Depth
| #include <iostream>
void recurse(unsigned int i)
{
std::cout<<i<<"\n";
recurse(i+1);
}
int main()
{
recurse(0);
}
|
Keep all operations the same but rewrite the snippet in C++. | function TestDepth ( $N )
{
$N
TestDepth ( $N + 1 )
}
try
{
TestDepth 1 | ForEach { $Depth = $_ }
}
catch
{
"Exception message: " + $_.Exception.Message
}
"Last level before error: " + $Depth
| #include <iostream>
void recurse(unsigned int i)
{
std::cout<<i<<"\n";
recurse(i+1);
}
int main()
{
recurse(0);
}
|
Rewrite this program in Java while keeping its functionality equivalent to the PowerShell version. | function TestDepth ( $N )
{
$N
TestDepth ( $N + 1 )
}
try
{
TestDepth 1 | ForEach { $Depth = $_ }
}
catch
{
"Exception message: " + $_.Exception.Message
}
"Last level before error: " + $Depth
| public class RecursionTest {
private static void recurse(int i) {
try {
recurse(i+1);
} catch (StackOverflowError e) {
System.out.print("Recursion depth on this system is " + i + ".");
}
}
public static void main(String[] args) {
recurse(0);
}
}
|
Convert this PowerShell snippet to Java and keep its semantics consistent. | function TestDepth ( $N )
{
$N
TestDepth ( $N + 1 )
}
try
{
TestDepth 1 | ForEach { $Depth = $_ }
}
catch
{
"Exception message: " + $_.Exception.Message
}
"Last level before error: " + $Depth
| public class RecursionTest {
private static void recurse(int i) {
try {
recurse(i+1);
} catch (StackOverflowError e) {
System.out.print("Recursion depth on this system is " + i + ".");
}
}
public static void main(String[] args) {
recurse(0);
}
}
|
Produce a language-to-language conversion: from PowerShell to Python, same semantics. | function TestDepth ( $N )
{
$N
TestDepth ( $N + 1 )
}
try
{
TestDepth 1 | ForEach { $Depth = $_ }
}
catch
{
"Exception message: " + $_.Exception.Message
}
"Last level before error: " + $Depth
| import sys
print(sys.getrecursionlimit())
|
Port the provided PowerShell code into Python while preserving the original functionality. | function TestDepth ( $N )
{
$N
TestDepth ( $N + 1 )
}
try
{
TestDepth 1 | ForEach { $Depth = $_ }
}
catch
{
"Exception message: " + $_.Exception.Message
}
"Last level before error: " + $Depth
| import sys
print(sys.getrecursionlimit())
|
Generate an equivalent VB version of this PowerShell code. | function TestDepth ( $N )
{
$N
TestDepth ( $N + 1 )
}
try
{
TestDepth 1 | ForEach { $Depth = $_ }
}
catch
{
"Exception message: " + $_.Exception.Message
}
"Last level before error: " + $Depth
| Option Explicit
Sub Main()
Debug.Print "The limit is : " & Limite_Recursivite(0)
End Sub
Function Limite_Recursivite(Cpt As Long) As Long
Cpt = Cpt + 1
On Error Resume Next
Limite_Recursivite Cpt
On Error GoTo 0
Limite_Recursivite = Cpt
End Function
|
Translate the given PowerShell code snippet into VB without altering its behavior. | function TestDepth ( $N )
{
$N
TestDepth ( $N + 1 )
}
try
{
TestDepth 1 | ForEach { $Depth = $_ }
}
catch
{
"Exception message: " + $_.Exception.Message
}
"Last level before error: " + $Depth
| Option Explicit
Sub Main()
Debug.Print "The limit is : " & Limite_Recursivite(0)
End Sub
Function Limite_Recursivite(Cpt As Long) As Long
Cpt = Cpt + 1
On Error Resume Next
Limite_Recursivite Cpt
On Error GoTo 0
Limite_Recursivite = Cpt
End Function
|
Generate an equivalent Go version of this PowerShell code. | function TestDepth ( $N )
{
$N
TestDepth ( $N + 1 )
}
try
{
TestDepth 1 | ForEach { $Depth = $_ }
}
catch
{
"Exception message: " + $_.Exception.Message
}
"Last level before error: " + $Depth
| package main
import (
"flag"
"fmt"
"runtime/debug"
)
func main() {
stack := flag.Int("stack", 0, "maximum per goroutine stack size or 0 for the default")
flag.Parse()
if *stack > 0 {
debug.SetMaxStack(*stack)
}
r(1)
}
func r(l int) {
if l%1000 == 0 {
fmt.Println(l)
}
r(l + 1)
}
|
Write the same code in Go as shown below in PowerShell. | function TestDepth ( $N )
{
$N
TestDepth ( $N + 1 )
}
try
{
TestDepth 1 | ForEach { $Depth = $_ }
}
catch
{
"Exception message: " + $_.Exception.Message
}
"Last level before error: " + $Depth
| package main
import (
"flag"
"fmt"
"runtime/debug"
)
func main() {
stack := flag.Int("stack", 0, "maximum per goroutine stack size or 0 for the default")
flag.Parse()
if *stack > 0 {
debug.SetMaxStack(*stack)
}
r(1)
}
func r(l int) {
if l%1000 == 0 {
fmt.Println(l)
}
r(l + 1)
}
|
Translate this program into C but keep the logic exactly as in R. |
options("expressions")
options(expressions = 10000)
recurse <- function(x)
{
print(x)
recurse(x+1)
}
recurse(0)
| #include <stdio.h>
void recurse(unsigned int i)
{
printf("%d\n", i);
recurse(i+1);
}
int main()
{
recurse(0);
return 0;
}
|
Produce a language-to-language conversion: from R to C, same semantics. |
options("expressions")
options(expressions = 10000)
recurse <- function(x)
{
print(x)
recurse(x+1)
}
recurse(0)
| #include <stdio.h>
void recurse(unsigned int i)
{
printf("%d\n", i);
recurse(i+1);
}
int main()
{
recurse(0);
return 0;
}
|
Transform the following R implementation into C#, maintaining the same output and logic. |
options("expressions")
options(expressions = 10000)
recurse <- function(x)
{
print(x)
recurse(x+1)
}
recurse(0)
| using System;
class RecursionLimit
{
static void Main(string[] args)
{
Recur(0);
}
private static void Recur(int i)
{
Console.WriteLine(i);
Recur(i + 1);
}
}
|
Convert this R snippet to C# and keep its semantics consistent. |
options("expressions")
options(expressions = 10000)
recurse <- function(x)
{
print(x)
recurse(x+1)
}
recurse(0)
| using System;
class RecursionLimit
{
static void Main(string[] args)
{
Recur(0);
}
private static void Recur(int i)
{
Console.WriteLine(i);
Recur(i + 1);
}
}
|
Change the following R code into C++ without altering its purpose. |
options("expressions")
options(expressions = 10000)
recurse <- function(x)
{
print(x)
recurse(x+1)
}
recurse(0)
| #include <iostream>
void recurse(unsigned int i)
{
std::cout<<i<<"\n";
recurse(i+1);
}
int main()
{
recurse(0);
}
|
Write a version of this R function in C++ with identical behavior. |
options("expressions")
options(expressions = 10000)
recurse <- function(x)
{
print(x)
recurse(x+1)
}
recurse(0)
| #include <iostream>
void recurse(unsigned int i)
{
std::cout<<i<<"\n";
recurse(i+1);
}
int main()
{
recurse(0);
}
|
Port the following code from R to Java with equivalent syntax and logic. |
options("expressions")
options(expressions = 10000)
recurse <- function(x)
{
print(x)
recurse(x+1)
}
recurse(0)
| public class RecursionTest {
private static void recurse(int i) {
try {
recurse(i+1);
} catch (StackOverflowError e) {
System.out.print("Recursion depth on this system is " + i + ".");
}
}
public static void main(String[] args) {
recurse(0);
}
}
|
Produce a functionally identical Java code for the snippet given in R. |
options("expressions")
options(expressions = 10000)
recurse <- function(x)
{
print(x)
recurse(x+1)
}
recurse(0)
| public class RecursionTest {
private static void recurse(int i) {
try {
recurse(i+1);
} catch (StackOverflowError e) {
System.out.print("Recursion depth on this system is " + i + ".");
}
}
public static void main(String[] args) {
recurse(0);
}
}
|
Write the same code in Python as shown below in R. |
options("expressions")
options(expressions = 10000)
recurse <- function(x)
{
print(x)
recurse(x+1)
}
recurse(0)
| import sys
print(sys.getrecursionlimit())
|
Translate the given R code snippet into Python without altering its behavior. |
options("expressions")
options(expressions = 10000)
recurse <- function(x)
{
print(x)
recurse(x+1)
}
recurse(0)
| import sys
print(sys.getrecursionlimit())
|
Preserve the algorithm and functionality while converting the code from R to VB. |
options("expressions")
options(expressions = 10000)
recurse <- function(x)
{
print(x)
recurse(x+1)
}
recurse(0)
| Option Explicit
Sub Main()
Debug.Print "The limit is : " & Limite_Recursivite(0)
End Sub
Function Limite_Recursivite(Cpt As Long) As Long
Cpt = Cpt + 1
On Error Resume Next
Limite_Recursivite Cpt
On Error GoTo 0
Limite_Recursivite = Cpt
End Function
|
Write a version of this R function in VB with identical behavior. |
options("expressions")
options(expressions = 10000)
recurse <- function(x)
{
print(x)
recurse(x+1)
}
recurse(0)
| Option Explicit
Sub Main()
Debug.Print "The limit is : " & Limite_Recursivite(0)
End Sub
Function Limite_Recursivite(Cpt As Long) As Long
Cpt = Cpt + 1
On Error Resume Next
Limite_Recursivite Cpt
On Error GoTo 0
Limite_Recursivite = Cpt
End Function
|
Write the same algorithm in Go as shown in this R implementation. |
options("expressions")
options(expressions = 10000)
recurse <- function(x)
{
print(x)
recurse(x+1)
}
recurse(0)
| package main
import (
"flag"
"fmt"
"runtime/debug"
)
func main() {
stack := flag.Int("stack", 0, "maximum per goroutine stack size or 0 for the default")
flag.Parse()
if *stack > 0 {
debug.SetMaxStack(*stack)
}
r(1)
}
func r(l int) {
if l%1000 == 0 {
fmt.Println(l)
}
r(l + 1)
}
|
Ensure the translated Go code behaves exactly like the original R snippet. |
options("expressions")
options(expressions = 10000)
recurse <- function(x)
{
print(x)
recurse(x+1)
}
recurse(0)
| package main
import (
"flag"
"fmt"
"runtime/debug"
)
func main() {
stack := flag.Int("stack", 0, "maximum per goroutine stack size or 0 for the default")
flag.Parse()
if *stack > 0 {
debug.SetMaxStack(*stack)
}
r(1)
}
func r(l int) {
if l%1000 == 0 {
fmt.Println(l)
}
r(l + 1)
}
|
Please provide an equivalent version of this Racket code in C. | #lang racket
(define (recursion-limit)
(with-handlers ((exn? (lambda (x) 0)))
(add1 (recursion-limit))))
| #include <stdio.h>
void recurse(unsigned int i)
{
printf("%d\n", i);
recurse(i+1);
}
int main()
{
recurse(0);
return 0;
}
|
Convert this Racket snippet to C and keep its semantics consistent. | #lang racket
(define (recursion-limit)
(with-handlers ((exn? (lambda (x) 0)))
(add1 (recursion-limit))))
| #include <stdio.h>
void recurse(unsigned int i)
{
printf("%d\n", i);
recurse(i+1);
}
int main()
{
recurse(0);
return 0;
}
|
Rewrite this program in C# while keeping its functionality equivalent to the Racket version. | #lang racket
(define (recursion-limit)
(with-handlers ((exn? (lambda (x) 0)))
(add1 (recursion-limit))))
| using System;
class RecursionLimit
{
static void Main(string[] args)
{
Recur(0);
}
private static void Recur(int i)
{
Console.WriteLine(i);
Recur(i + 1);
}
}
|
Preserve the algorithm and functionality while converting the code from Racket to C#. | #lang racket
(define (recursion-limit)
(with-handlers ((exn? (lambda (x) 0)))
(add1 (recursion-limit))))
| using System;
class RecursionLimit
{
static void Main(string[] args)
{
Recur(0);
}
private static void Recur(int i)
{
Console.WriteLine(i);
Recur(i + 1);
}
}
|
Produce a language-to-language conversion: from Racket to C++, same semantics. | #lang racket
(define (recursion-limit)
(with-handlers ((exn? (lambda (x) 0)))
(add1 (recursion-limit))))
| #include <iostream>
void recurse(unsigned int i)
{
std::cout<<i<<"\n";
recurse(i+1);
}
int main()
{
recurse(0);
}
|
Change the programming language of this snippet from Racket to C++ without modifying what it does. | #lang racket
(define (recursion-limit)
(with-handlers ((exn? (lambda (x) 0)))
(add1 (recursion-limit))))
| #include <iostream>
void recurse(unsigned int i)
{
std::cout<<i<<"\n";
recurse(i+1);
}
int main()
{
recurse(0);
}
|
Write the same code in Java as shown below in Racket. | #lang racket
(define (recursion-limit)
(with-handlers ((exn? (lambda (x) 0)))
(add1 (recursion-limit))))
| public class RecursionTest {
private static void recurse(int i) {
try {
recurse(i+1);
} catch (StackOverflowError e) {
System.out.print("Recursion depth on this system is " + i + ".");
}
}
public static void main(String[] args) {
recurse(0);
}
}
|
Rewrite this program in Java while keeping its functionality equivalent to the Racket version. | #lang racket
(define (recursion-limit)
(with-handlers ((exn? (lambda (x) 0)))
(add1 (recursion-limit))))
| public class RecursionTest {
private static void recurse(int i) {
try {
recurse(i+1);
} catch (StackOverflowError e) {
System.out.print("Recursion depth on this system is " + i + ".");
}
}
public static void main(String[] args) {
recurse(0);
}
}
|
Convert this Racket snippet to Python and keep its semantics consistent. | #lang racket
(define (recursion-limit)
(with-handlers ((exn? (lambda (x) 0)))
(add1 (recursion-limit))))
| import sys
print(sys.getrecursionlimit())
|
Port the provided Racket code into Python while preserving the original functionality. | #lang racket
(define (recursion-limit)
(with-handlers ((exn? (lambda (x) 0)))
(add1 (recursion-limit))))
| import sys
print(sys.getrecursionlimit())
|
Translate this program into VB but keep the logic exactly as in Racket. | #lang racket
(define (recursion-limit)
(with-handlers ((exn? (lambda (x) 0)))
(add1 (recursion-limit))))
| Option Explicit
Sub Main()
Debug.Print "The limit is : " & Limite_Recursivite(0)
End Sub
Function Limite_Recursivite(Cpt As Long) As Long
Cpt = Cpt + 1
On Error Resume Next
Limite_Recursivite Cpt
On Error GoTo 0
Limite_Recursivite = Cpt
End Function
|
Please provide an equivalent version of this Racket code in VB. | #lang racket
(define (recursion-limit)
(with-handlers ((exn? (lambda (x) 0)))
(add1 (recursion-limit))))
| Option Explicit
Sub Main()
Debug.Print "The limit is : " & Limite_Recursivite(0)
End Sub
Function Limite_Recursivite(Cpt As Long) As Long
Cpt = Cpt + 1
On Error Resume Next
Limite_Recursivite Cpt
On Error GoTo 0
Limite_Recursivite = Cpt
End Function
|
Can you help me rewrite this code in Go instead of Racket, keeping it the same logically? | #lang racket
(define (recursion-limit)
(with-handlers ((exn? (lambda (x) 0)))
(add1 (recursion-limit))))
| package main
import (
"flag"
"fmt"
"runtime/debug"
)
func main() {
stack := flag.Int("stack", 0, "maximum per goroutine stack size or 0 for the default")
flag.Parse()
if *stack > 0 {
debug.SetMaxStack(*stack)
}
r(1)
}
func r(l int) {
if l%1000 == 0 {
fmt.Println(l)
}
r(l + 1)
}
|
Rewrite the snippet below in Go so it works the same as the original Racket code. | #lang racket
(define (recursion-limit)
(with-handlers ((exn? (lambda (x) 0)))
(add1 (recursion-limit))))
| package main
import (
"flag"
"fmt"
"runtime/debug"
)
func main() {
stack := flag.Int("stack", 0, "maximum per goroutine stack size or 0 for the default")
flag.Parse()
if *stack > 0 {
debug.SetMaxStack(*stack)
}
r(1)
}
func r(l int) {
if l%1000 == 0 {
fmt.Println(l)
}
r(l + 1)
}
|
Can you help me rewrite this code in C instead of COBOL, keeping it the same logically? | identification division.
program-id. recurse.
data division.
working-storage section.
01 depth-counter pic 9(3).
01 install-address usage is procedure-pointer.
01 install-flag pic x comp-x value 0.
01 status-code pic x(2) comp-5.
01 ind pic s9(9) comp-5.
linkage section.
01 err-msg pic x(325).
procedure division.
100-main.
set install-address to entry "300-err".
call "CBL_ERROR_PROC" using install-flag
install-address
returning status-code.
if status-code not = 0
display "ERROR INSTALLING ERROR PROC"
stop run
end-if
move 0 to depth-counter.
display 'Mung until no good.'.
perform 200-mung.
display 'No good.'.
stop run.
200-mung.
add 1 to depth-counter.
display depth-counter.
perform 200-mung.
300-err.
entry "300-err" using err-msg.
perform varying ind from 1 by 1
until (err-msg(ind:1) = x"00") or (ind = length of err-msg)
continue
end-perform
display err-msg(1:ind).
exit program.
| #include <stdio.h>
void recurse(unsigned int i)
{
printf("%d\n", i);
recurse(i+1);
}
int main()
{
recurse(0);
return 0;
}
|
Write a version of this COBOL function in C with identical behavior. | identification division.
program-id. recurse.
data division.
working-storage section.
01 depth-counter pic 9(3).
01 install-address usage is procedure-pointer.
01 install-flag pic x comp-x value 0.
01 status-code pic x(2) comp-5.
01 ind pic s9(9) comp-5.
linkage section.
01 err-msg pic x(325).
procedure division.
100-main.
set install-address to entry "300-err".
call "CBL_ERROR_PROC" using install-flag
install-address
returning status-code.
if status-code not = 0
display "ERROR INSTALLING ERROR PROC"
stop run
end-if
move 0 to depth-counter.
display 'Mung until no good.'.
perform 200-mung.
display 'No good.'.
stop run.
200-mung.
add 1 to depth-counter.
display depth-counter.
perform 200-mung.
300-err.
entry "300-err" using err-msg.
perform varying ind from 1 by 1
until (err-msg(ind:1) = x"00") or (ind = length of err-msg)
continue
end-perform
display err-msg(1:ind).
exit program.
| #include <stdio.h>
void recurse(unsigned int i)
{
printf("%d\n", i);
recurse(i+1);
}
int main()
{
recurse(0);
return 0;
}
|
Port the provided COBOL code into C# while preserving the original functionality. | identification division.
program-id. recurse.
data division.
working-storage section.
01 depth-counter pic 9(3).
01 install-address usage is procedure-pointer.
01 install-flag pic x comp-x value 0.
01 status-code pic x(2) comp-5.
01 ind pic s9(9) comp-5.
linkage section.
01 err-msg pic x(325).
procedure division.
100-main.
set install-address to entry "300-err".
call "CBL_ERROR_PROC" using install-flag
install-address
returning status-code.
if status-code not = 0
display "ERROR INSTALLING ERROR PROC"
stop run
end-if
move 0 to depth-counter.
display 'Mung until no good.'.
perform 200-mung.
display 'No good.'.
stop run.
200-mung.
add 1 to depth-counter.
display depth-counter.
perform 200-mung.
300-err.
entry "300-err" using err-msg.
perform varying ind from 1 by 1
until (err-msg(ind:1) = x"00") or (ind = length of err-msg)
continue
end-perform
display err-msg(1:ind).
exit program.
| using System;
class RecursionLimit
{
static void Main(string[] args)
{
Recur(0);
}
private static void Recur(int i)
{
Console.WriteLine(i);
Recur(i + 1);
}
}
|
Generate an equivalent C# version of this COBOL code. | identification division.
program-id. recurse.
data division.
working-storage section.
01 depth-counter pic 9(3).
01 install-address usage is procedure-pointer.
01 install-flag pic x comp-x value 0.
01 status-code pic x(2) comp-5.
01 ind pic s9(9) comp-5.
linkage section.
01 err-msg pic x(325).
procedure division.
100-main.
set install-address to entry "300-err".
call "CBL_ERROR_PROC" using install-flag
install-address
returning status-code.
if status-code not = 0
display "ERROR INSTALLING ERROR PROC"
stop run
end-if
move 0 to depth-counter.
display 'Mung until no good.'.
perform 200-mung.
display 'No good.'.
stop run.
200-mung.
add 1 to depth-counter.
display depth-counter.
perform 200-mung.
300-err.
entry "300-err" using err-msg.
perform varying ind from 1 by 1
until (err-msg(ind:1) = x"00") or (ind = length of err-msg)
continue
end-perform
display err-msg(1:ind).
exit program.
| using System;
class RecursionLimit
{
static void Main(string[] args)
{
Recur(0);
}
private static void Recur(int i)
{
Console.WriteLine(i);
Recur(i + 1);
}
}
|
Generate a C++ translation of this COBOL snippet without changing its computational steps. | identification division.
program-id. recurse.
data division.
working-storage section.
01 depth-counter pic 9(3).
01 install-address usage is procedure-pointer.
01 install-flag pic x comp-x value 0.
01 status-code pic x(2) comp-5.
01 ind pic s9(9) comp-5.
linkage section.
01 err-msg pic x(325).
procedure division.
100-main.
set install-address to entry "300-err".
call "CBL_ERROR_PROC" using install-flag
install-address
returning status-code.
if status-code not = 0
display "ERROR INSTALLING ERROR PROC"
stop run
end-if
move 0 to depth-counter.
display 'Mung until no good.'.
perform 200-mung.
display 'No good.'.
stop run.
200-mung.
add 1 to depth-counter.
display depth-counter.
perform 200-mung.
300-err.
entry "300-err" using err-msg.
perform varying ind from 1 by 1
until (err-msg(ind:1) = x"00") or (ind = length of err-msg)
continue
end-perform
display err-msg(1:ind).
exit program.
| #include <iostream>
void recurse(unsigned int i)
{
std::cout<<i<<"\n";
recurse(i+1);
}
int main()
{
recurse(0);
}
|
Preserve the algorithm and functionality while converting the code from COBOL to C++. | identification division.
program-id. recurse.
data division.
working-storage section.
01 depth-counter pic 9(3).
01 install-address usage is procedure-pointer.
01 install-flag pic x comp-x value 0.
01 status-code pic x(2) comp-5.
01 ind pic s9(9) comp-5.
linkage section.
01 err-msg pic x(325).
procedure division.
100-main.
set install-address to entry "300-err".
call "CBL_ERROR_PROC" using install-flag
install-address
returning status-code.
if status-code not = 0
display "ERROR INSTALLING ERROR PROC"
stop run
end-if
move 0 to depth-counter.
display 'Mung until no good.'.
perform 200-mung.
display 'No good.'.
stop run.
200-mung.
add 1 to depth-counter.
display depth-counter.
perform 200-mung.
300-err.
entry "300-err" using err-msg.
perform varying ind from 1 by 1
until (err-msg(ind:1) = x"00") or (ind = length of err-msg)
continue
end-perform
display err-msg(1:ind).
exit program.
| #include <iostream>
void recurse(unsigned int i)
{
std::cout<<i<<"\n";
recurse(i+1);
}
int main()
{
recurse(0);
}
|
Ensure the translated Java code behaves exactly like the original COBOL snippet. | identification division.
program-id. recurse.
data division.
working-storage section.
01 depth-counter pic 9(3).
01 install-address usage is procedure-pointer.
01 install-flag pic x comp-x value 0.
01 status-code pic x(2) comp-5.
01 ind pic s9(9) comp-5.
linkage section.
01 err-msg pic x(325).
procedure division.
100-main.
set install-address to entry "300-err".
call "CBL_ERROR_PROC" using install-flag
install-address
returning status-code.
if status-code not = 0
display "ERROR INSTALLING ERROR PROC"
stop run
end-if
move 0 to depth-counter.
display 'Mung until no good.'.
perform 200-mung.
display 'No good.'.
stop run.
200-mung.
add 1 to depth-counter.
display depth-counter.
perform 200-mung.
300-err.
entry "300-err" using err-msg.
perform varying ind from 1 by 1
until (err-msg(ind:1) = x"00") or (ind = length of err-msg)
continue
end-perform
display err-msg(1:ind).
exit program.
| public class RecursionTest {
private static void recurse(int i) {
try {
recurse(i+1);
} catch (StackOverflowError e) {
System.out.print("Recursion depth on this system is " + i + ".");
}
}
public static void main(String[] args) {
recurse(0);
}
}
|
Generate a Java translation of this COBOL snippet without changing its computational steps. | identification division.
program-id. recurse.
data division.
working-storage section.
01 depth-counter pic 9(3).
01 install-address usage is procedure-pointer.
01 install-flag pic x comp-x value 0.
01 status-code pic x(2) comp-5.
01 ind pic s9(9) comp-5.
linkage section.
01 err-msg pic x(325).
procedure division.
100-main.
set install-address to entry "300-err".
call "CBL_ERROR_PROC" using install-flag
install-address
returning status-code.
if status-code not = 0
display "ERROR INSTALLING ERROR PROC"
stop run
end-if
move 0 to depth-counter.
display 'Mung until no good.'.
perform 200-mung.
display 'No good.'.
stop run.
200-mung.
add 1 to depth-counter.
display depth-counter.
perform 200-mung.
300-err.
entry "300-err" using err-msg.
perform varying ind from 1 by 1
until (err-msg(ind:1) = x"00") or (ind = length of err-msg)
continue
end-perform
display err-msg(1:ind).
exit program.
| public class RecursionTest {
private static void recurse(int i) {
try {
recurse(i+1);
} catch (StackOverflowError e) {
System.out.print("Recursion depth on this system is " + i + ".");
}
}
public static void main(String[] args) {
recurse(0);
}
}
|
Translate this program into Python but keep the logic exactly as in COBOL. | identification division.
program-id. recurse.
data division.
working-storage section.
01 depth-counter pic 9(3).
01 install-address usage is procedure-pointer.
01 install-flag pic x comp-x value 0.
01 status-code pic x(2) comp-5.
01 ind pic s9(9) comp-5.
linkage section.
01 err-msg pic x(325).
procedure division.
100-main.
set install-address to entry "300-err".
call "CBL_ERROR_PROC" using install-flag
install-address
returning status-code.
if status-code not = 0
display "ERROR INSTALLING ERROR PROC"
stop run
end-if
move 0 to depth-counter.
display 'Mung until no good.'.
perform 200-mung.
display 'No good.'.
stop run.
200-mung.
add 1 to depth-counter.
display depth-counter.
perform 200-mung.
300-err.
entry "300-err" using err-msg.
perform varying ind from 1 by 1
until (err-msg(ind:1) = x"00") or (ind = length of err-msg)
continue
end-perform
display err-msg(1:ind).
exit program.
| import sys
print(sys.getrecursionlimit())
|
Translate the given COBOL code snippet into Python without altering its behavior. | identification division.
program-id. recurse.
data division.
working-storage section.
01 depth-counter pic 9(3).
01 install-address usage is procedure-pointer.
01 install-flag pic x comp-x value 0.
01 status-code pic x(2) comp-5.
01 ind pic s9(9) comp-5.
linkage section.
01 err-msg pic x(325).
procedure division.
100-main.
set install-address to entry "300-err".
call "CBL_ERROR_PROC" using install-flag
install-address
returning status-code.
if status-code not = 0
display "ERROR INSTALLING ERROR PROC"
stop run
end-if
move 0 to depth-counter.
display 'Mung until no good.'.
perform 200-mung.
display 'No good.'.
stop run.
200-mung.
add 1 to depth-counter.
display depth-counter.
perform 200-mung.
300-err.
entry "300-err" using err-msg.
perform varying ind from 1 by 1
until (err-msg(ind:1) = x"00") or (ind = length of err-msg)
continue
end-perform
display err-msg(1:ind).
exit program.
| import sys
print(sys.getrecursionlimit())
|
Maintain the same structure and functionality when rewriting this code in VB. | identification division.
program-id. recurse.
data division.
working-storage section.
01 depth-counter pic 9(3).
01 install-address usage is procedure-pointer.
01 install-flag pic x comp-x value 0.
01 status-code pic x(2) comp-5.
01 ind pic s9(9) comp-5.
linkage section.
01 err-msg pic x(325).
procedure division.
100-main.
set install-address to entry "300-err".
call "CBL_ERROR_PROC" using install-flag
install-address
returning status-code.
if status-code not = 0
display "ERROR INSTALLING ERROR PROC"
stop run
end-if
move 0 to depth-counter.
display 'Mung until no good.'.
perform 200-mung.
display 'No good.'.
stop run.
200-mung.
add 1 to depth-counter.
display depth-counter.
perform 200-mung.
300-err.
entry "300-err" using err-msg.
perform varying ind from 1 by 1
until (err-msg(ind:1) = x"00") or (ind = length of err-msg)
continue
end-perform
display err-msg(1:ind).
exit program.
| Option Explicit
Sub Main()
Debug.Print "The limit is : " & Limite_Recursivite(0)
End Sub
Function Limite_Recursivite(Cpt As Long) As Long
Cpt = Cpt + 1
On Error Resume Next
Limite_Recursivite Cpt
On Error GoTo 0
Limite_Recursivite = Cpt
End Function
|
Convert the following code from COBOL to VB, ensuring the logic remains intact. | identification division.
program-id. recurse.
data division.
working-storage section.
01 depth-counter pic 9(3).
01 install-address usage is procedure-pointer.
01 install-flag pic x comp-x value 0.
01 status-code pic x(2) comp-5.
01 ind pic s9(9) comp-5.
linkage section.
01 err-msg pic x(325).
procedure division.
100-main.
set install-address to entry "300-err".
call "CBL_ERROR_PROC" using install-flag
install-address
returning status-code.
if status-code not = 0
display "ERROR INSTALLING ERROR PROC"
stop run
end-if
move 0 to depth-counter.
display 'Mung until no good.'.
perform 200-mung.
display 'No good.'.
stop run.
200-mung.
add 1 to depth-counter.
display depth-counter.
perform 200-mung.
300-err.
entry "300-err" using err-msg.
perform varying ind from 1 by 1
until (err-msg(ind:1) = x"00") or (ind = length of err-msg)
continue
end-perform
display err-msg(1:ind).
exit program.
| Option Explicit
Sub Main()
Debug.Print "The limit is : " & Limite_Recursivite(0)
End Sub
Function Limite_Recursivite(Cpt As Long) As Long
Cpt = Cpt + 1
On Error Resume Next
Limite_Recursivite Cpt
On Error GoTo 0
Limite_Recursivite = Cpt
End Function
|
Convert this COBOL block to Go, preserving its control flow and logic. | identification division.
program-id. recurse.
data division.
working-storage section.
01 depth-counter pic 9(3).
01 install-address usage is procedure-pointer.
01 install-flag pic x comp-x value 0.
01 status-code pic x(2) comp-5.
01 ind pic s9(9) comp-5.
linkage section.
01 err-msg pic x(325).
procedure division.
100-main.
set install-address to entry "300-err".
call "CBL_ERROR_PROC" using install-flag
install-address
returning status-code.
if status-code not = 0
display "ERROR INSTALLING ERROR PROC"
stop run
end-if
move 0 to depth-counter.
display 'Mung until no good.'.
perform 200-mung.
display 'No good.'.
stop run.
200-mung.
add 1 to depth-counter.
display depth-counter.
perform 200-mung.
300-err.
entry "300-err" using err-msg.
perform varying ind from 1 by 1
until (err-msg(ind:1) = x"00") or (ind = length of err-msg)
continue
end-perform
display err-msg(1:ind).
exit program.
| package main
import (
"flag"
"fmt"
"runtime/debug"
)
func main() {
stack := flag.Int("stack", 0, "maximum per goroutine stack size or 0 for the default")
flag.Parse()
if *stack > 0 {
debug.SetMaxStack(*stack)
}
r(1)
}
func r(l int) {
if l%1000 == 0 {
fmt.Println(l)
}
r(l + 1)
}
|
Can you help me rewrite this code in Go instead of COBOL, keeping it the same logically? | identification division.
program-id. recurse.
data division.
working-storage section.
01 depth-counter pic 9(3).
01 install-address usage is procedure-pointer.
01 install-flag pic x comp-x value 0.
01 status-code pic x(2) comp-5.
01 ind pic s9(9) comp-5.
linkage section.
01 err-msg pic x(325).
procedure division.
100-main.
set install-address to entry "300-err".
call "CBL_ERROR_PROC" using install-flag
install-address
returning status-code.
if status-code not = 0
display "ERROR INSTALLING ERROR PROC"
stop run
end-if
move 0 to depth-counter.
display 'Mung until no good.'.
perform 200-mung.
display 'No good.'.
stop run.
200-mung.
add 1 to depth-counter.
display depth-counter.
perform 200-mung.
300-err.
entry "300-err" using err-msg.
perform varying ind from 1 by 1
until (err-msg(ind:1) = x"00") or (ind = length of err-msg)
continue
end-perform
display err-msg(1:ind).
exit program.
| package main
import (
"flag"
"fmt"
"runtime/debug"
)
func main() {
stack := flag.Int("stack", 0, "maximum per goroutine stack size or 0 for the default")
flag.Parse()
if *stack > 0 {
debug.SetMaxStack(*stack)
}
r(1)
}
func r(l int) {
if l%1000 == 0 {
fmt.Println(l)
}
r(l + 1)
}
|
Produce a language-to-language conversion: from REXX to C, same semantics. |
options replace format comments java crossref symbols binary
import java.lang.management.
memoryInfo()
digDeeper(0)
* Just keep digging
* @param level depth gauge
*/
method digDeeper(level = int) private static binary
do
digDeeper(level + 1)
catch ex = Error
System.out.println('Recursion got' level 'levels deep on this system.')
System.out.println('Recursion stopped by' ex.getClass.getName())
end
return
* Display some memory usage from the JVM
* @see ManagementFactory
* @see MemoryMXBean
* @see MemoryUsage
*/
method memoryInfo() private static
mxBean = ManagementFactory.getMemoryMXBean() -- get the MemoryMXBean
hmMemoryUsage = mxBean.getHeapMemoryUsage() -- get the heap MemoryUsage object
nmMemoryUsage = mxBean.getNonHeapMemoryUsage() -- get the non-heap MemoryUsage object
say 'JVM Memory Information:'
say ' Heap:' hmMemoryUsage.toString()
say ' Non-Heap:' nmMemoryUsage.toString()
say '-'.left(120, '-')
say
return
| #include <stdio.h>
void recurse(unsigned int i)
{
printf("%d\n", i);
recurse(i+1);
}
int main()
{
recurse(0);
return 0;
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.