Instruction stringlengths 45 106 | input_code stringlengths 1 13.7k | output_code stringlengths 1 13.7k |
|---|---|---|
Preserve the algorithm and functionality while converting the code from REXX to C. |
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;
}
|
Convert this REXX snippet to C# and keep its semantics consistent. |
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
| 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 REXX to C# with equivalent syntax and logic. |
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
| 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 REXX snippet without changing its computational steps. |
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 <iostream>
void recurse(unsigned int i)
{
std::cout<<i<<"\n";
recurse(i+1);
}
int main()
{
recurse(0);
}
|
Convert this REXX block to C++, preserving its control flow and logic. |
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 <iostream>
void recurse(unsigned int i)
{
std::cout<<i<<"\n";
recurse(i+1);
}
int main()
{
recurse(0);
}
|
Convert the following code from REXX to Java, ensuring the logic remains intact. |
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
| 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);
}
}
|
Can you help me rewrite this code in Java instead of REXX, keeping it the same logically? |
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
| 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 REXX code into Python while preserving the original functionality. |
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
| import sys
print(sys.getrecursionlimit())
|
Produce a functionally identical Python code for the snippet given in REXX. |
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
| import sys
print(sys.getrecursionlimit())
|
Produce a language-to-language conversion: from REXX to VB, 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
| 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 functionally identical VB code for the snippet given in REXX. |
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
| 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 REXX code. |
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
| 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)
}
|
Keep all operations the same but rewrite the snippet in Go. |
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
| 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)
}
|
Preserve the algorithm and functionality while converting the code from Ruby to C. | def recurse x
puts x
recurse(x+1)
end
recurse(0)
| #include <stdio.h>
void recurse(unsigned int i)
{
printf("%d\n", i);
recurse(i+1);
}
int main()
{
recurse(0);
return 0;
}
|
Translate the given Ruby code snippet into C without altering its behavior. | def recurse x
puts x
recurse(x+1)
end
recurse(0)
| #include <stdio.h>
void recurse(unsigned int i)
{
printf("%d\n", i);
recurse(i+1);
}
int main()
{
recurse(0);
return 0;
}
|
Change the following Ruby code into C# without altering its purpose. | def recurse x
puts x
recurse(x+1)
end
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 Ruby code into C# without altering its purpose. | def recurse x
puts x
recurse(x+1)
end
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 Ruby snippet. | def recurse x
puts x
recurse(x+1)
end
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 C++ so it works the same as the original Ruby code. | def recurse x
puts x
recurse(x+1)
end
recurse(0)
| #include <iostream>
void recurse(unsigned int i)
{
std::cout<<i<<"\n";
recurse(i+1);
}
int main()
{
recurse(0);
}
|
Write the same algorithm in Java as shown in this Ruby implementation. | def recurse x
puts x
recurse(x+1)
end
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 a version of this Ruby function in Java with identical behavior. | def recurse x
puts x
recurse(x+1)
end
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);
}
}
|
Port the provided Ruby code into VB while preserving the original functionality. | def recurse x
puts x
recurse(x+1)
end
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
|
Keep all operations the same but rewrite the snippet in VB. | def recurse x
puts x
recurse(x+1)
end
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
|
Convert this Ruby snippet to Go and keep its semantics consistent. | def recurse x
puts x
recurse(x+1)
end
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 Ruby code into Go while preserving the original functionality. | def recurse x
puts x
recurse(x+1)
end
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)
}
|
Translate the given Scala code snippet into C without altering its behavior. |
fun recurse(i: Int) {
try {
recurse(i + 1)
}
catch(e: StackOverflowError) {
println("Limit of recursion is $i")
}
}
fun main(args: Array<String>) = 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 Scala code into C while preserving the original functionality. |
fun recurse(i: Int) {
try {
recurse(i + 1)
}
catch(e: StackOverflowError) {
println("Limit of recursion is $i")
}
}
fun main(args: Array<String>) = recurse(0)
| #include <stdio.h>
void recurse(unsigned int i)
{
printf("%d\n", i);
recurse(i+1);
}
int main()
{
recurse(0);
return 0;
}
|
Change the following Scala code into C# without altering its purpose. |
fun recurse(i: Int) {
try {
recurse(i + 1)
}
catch(e: StackOverflowError) {
println("Limit of recursion is $i")
}
}
fun main(args: Array<String>) = 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);
}
}
|
Preserve the algorithm and functionality while converting the code from Scala to C#. |
fun recurse(i: Int) {
try {
recurse(i + 1)
}
catch(e: StackOverflowError) {
println("Limit of recursion is $i")
}
}
fun main(args: Array<String>) = 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 Scala snippet to C++ and keep its semantics consistent. |
fun recurse(i: Int) {
try {
recurse(i + 1)
}
catch(e: StackOverflowError) {
println("Limit of recursion is $i")
}
}
fun main(args: Array<String>) = recurse(0)
| #include <iostream>
void recurse(unsigned int i)
{
std::cout<<i<<"\n";
recurse(i+1);
}
int main()
{
recurse(0);
}
|
Change the following Scala code into C++ without altering its purpose. |
fun recurse(i: Int) {
try {
recurse(i + 1)
}
catch(e: StackOverflowError) {
println("Limit of recursion is $i")
}
}
fun main(args: Array<String>) = recurse(0)
| #include <iostream>
void recurse(unsigned int i)
{
std::cout<<i<<"\n";
recurse(i+1);
}
int main()
{
recurse(0);
}
|
Port the provided Scala code into Java while preserving the original functionality. |
fun recurse(i: Int) {
try {
recurse(i + 1)
}
catch(e: StackOverflowError) {
println("Limit of recursion is $i")
}
}
fun main(args: Array<String>) = 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);
}
}
|
Preserve the algorithm and functionality while converting the code from Scala to Java. |
fun recurse(i: Int) {
try {
recurse(i + 1)
}
catch(e: StackOverflowError) {
println("Limit of recursion is $i")
}
}
fun main(args: Array<String>) = 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 Scala implementation into Python, maintaining the same output and logic. |
fun recurse(i: Int) {
try {
recurse(i + 1)
}
catch(e: StackOverflowError) {
println("Limit of recursion is $i")
}
}
fun main(args: Array<String>) = recurse(0)
| import sys
print(sys.getrecursionlimit())
|
Write a version of this Scala function in Python with identical behavior. |
fun recurse(i: Int) {
try {
recurse(i + 1)
}
catch(e: StackOverflowError) {
println("Limit of recursion is $i")
}
}
fun main(args: Array<String>) = recurse(0)
| import sys
print(sys.getrecursionlimit())
|
Keep all operations the same but rewrite the snippet in VB. |
fun recurse(i: Int) {
try {
recurse(i + 1)
}
catch(e: StackOverflowError) {
println("Limit of recursion is $i")
}
}
fun main(args: Array<String>) = 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
|
Rewrite the snippet below in VB so it works the same as the original Scala code. |
fun recurse(i: Int) {
try {
recurse(i + 1)
}
catch(e: StackOverflowError) {
println("Limit of recursion is $i")
}
}
fun main(args: Array<String>) = 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 Scala code in Go. |
fun recurse(i: Int) {
try {
recurse(i + 1)
}
catch(e: StackOverflowError) {
println("Limit of recursion is $i")
}
}
fun main(args: Array<String>) = 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)
}
|
Preserve the algorithm and functionality while converting the code from Scala to Go. |
fun recurse(i: Int) {
try {
recurse(i + 1)
}
catch(e: StackOverflowError) {
println("Limit of recursion is $i")
}
}
fun main(args: Array<String>) = 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)
}
|
Translate this program into C but keep the logic exactly as in Swift. | var n = 1
func recurse() {
print(n)
n += 1
recurse()
}
recurse()
| #include <stdio.h>
void recurse(unsigned int i)
{
printf("%d\n", i);
recurse(i+1);
}
int main()
{
recurse(0);
return 0;
}
|
Generate a C translation of this Swift snippet without changing its computational steps. | var n = 1
func recurse() {
print(n)
n += 1
recurse()
}
recurse()
| #include <stdio.h>
void recurse(unsigned int i)
{
printf("%d\n", i);
recurse(i+1);
}
int main()
{
recurse(0);
return 0;
}
|
Preserve the algorithm and functionality while converting the code from Swift to C#. | var n = 1
func recurse() {
print(n)
n += 1
recurse()
}
recurse()
| using System;
class RecursionLimit
{
static void Main(string[] args)
{
Recur(0);
}
private static void Recur(int i)
{
Console.WriteLine(i);
Recur(i + 1);
}
}
|
Translate the given Swift code snippet into C# without altering its behavior. | var n = 1
func recurse() {
print(n)
n += 1
recurse()
}
recurse()
| using System;
class RecursionLimit
{
static void Main(string[] args)
{
Recur(0);
}
private static void Recur(int i)
{
Console.WriteLine(i);
Recur(i + 1);
}
}
|
Write a version of this Swift function in C++ with identical behavior. | var n = 1
func recurse() {
print(n)
n += 1
recurse()
}
recurse()
| #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++. | var n = 1
func recurse() {
print(n)
n += 1
recurse()
}
recurse()
| #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 Swift. | var n = 1
func recurse() {
print(n)
n += 1
recurse()
}
recurse()
| 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 Swift snippet to Java and keep its semantics consistent. | var n = 1
func recurse() {
print(n)
n += 1
recurse()
}
recurse()
| 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);
}
}
|
Can you help me rewrite this code in Python instead of Swift, keeping it the same logically? | var n = 1
func recurse() {
print(n)
n += 1
recurse()
}
recurse()
| import sys
print(sys.getrecursionlimit())
|
Can you help me rewrite this code in Python instead of Swift, keeping it the same logically? | var n = 1
func recurse() {
print(n)
n += 1
recurse()
}
recurse()
| import sys
print(sys.getrecursionlimit())
|
Port the provided Swift code into VB while preserving the original functionality. | var n = 1
func recurse() {
print(n)
n += 1
recurse()
}
recurse()
| 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
|
Ensure the translated VB code behaves exactly like the original Swift snippet. | var n = 1
func recurse() {
print(n)
n += 1
recurse()
}
recurse()
| 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 this program into Go but keep the logic exactly as in Swift. | var n = 1
func recurse() {
print(n)
n += 1
recurse()
}
recurse()
| 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)
}
|
Change the following Swift code into Go without altering its purpose. | var n = 1
func recurse() {
print(n)
n += 1
recurse()
}
recurse()
| 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 C so it works the same as the original Tcl code. | proc recur i {
puts "This is depth [incr i]"
catch {recur $i};
}
recur 0
| #include <stdio.h>
void recurse(unsigned int i)
{
printf("%d\n", i);
recurse(i+1);
}
int main()
{
recurse(0);
return 0;
}
|
Produce a functionally identical C code for the snippet given in Tcl. | proc recur i {
puts "This is depth [incr i]"
catch {recur $i};
}
recur 0
| #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 Tcl snippet. | proc recur i {
puts "This is depth [incr i]"
catch {recur $i};
}
recur 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 the following code from Tcl to C#, ensuring the logic remains intact. | proc recur i {
puts "This is depth [incr i]"
catch {recur $i};
}
recur 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 Tcl snippet to C++ and keep its semantics consistent. | proc recur i {
puts "This is depth [incr i]"
catch {recur $i};
}
recur 0
| #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++. | proc recur i {
puts "This is depth [incr i]"
catch {recur $i};
}
recur 0
| #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 Tcl. | proc recur i {
puts "This is depth [incr i]"
catch {recur $i};
}
recur 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);
}
}
|
Rewrite the snippet below in Java so it works the same as the original Tcl code. | proc recur i {
puts "This is depth [incr i]"
catch {recur $i};
}
recur 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);
}
}
|
Rewrite this program in Python while keeping its functionality equivalent to the Tcl version. | proc recur i {
puts "This is depth [incr i]"
catch {recur $i};
}
recur 0
| import sys
print(sys.getrecursionlimit())
|
Produce a language-to-language conversion: from Tcl to Python, same semantics. | proc recur i {
puts "This is depth [incr i]"
catch {recur $i};
}
recur 0
| import sys
print(sys.getrecursionlimit())
|
Change the programming language of this snippet from Tcl to VB without modifying what it does. | proc recur i {
puts "This is depth [incr i]"
catch {recur $i};
}
recur 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
|
Port the following code from Tcl to VB with equivalent syntax and logic. | proc recur i {
puts "This is depth [incr i]"
catch {recur $i};
}
recur 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
|
Produce a functionally identical Go code for the snippet given in Tcl. | proc recur i {
puts "This is depth [incr i]"
catch {recur $i};
}
recur 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)
}
|
Write the same code in Go as shown below in Tcl. | proc recur i {
puts "This is depth [incr i]"
catch {recur $i};
}
recur 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 following code from Rust to PHP with equivalent syntax and logic. | fn recurse(n: i32) {
println!("depth: {}", n);
recurse(n + 1)
}
fn main() {
recurse(0);
}
| <?php
function a() {
static $i = 0;
print ++$i . "\n";
a();
}
a();
|
Rewrite the snippet below in PHP so it works the same as the original Rust code. | fn recurse(n: i32) {
println!("depth: {}", n);
recurse(n + 1)
}
fn main() {
recurse(0);
}
| <?php
function a() {
static $i = 0;
print ++$i . "\n";
a();
}
a();
|
Port the provided Ada code into PHP while preserving the original functionality. | with Ada.Text_IO; use Ada.Text_IO;
procedure Test_Recursion_Depth is
function Recursion (Depth : Positive) return Positive is
begin
return Recursion (Depth + 1);
exception
when Storage_Error =>
return Depth;
end Recursion;
begin
Put_Line ("Recursion depth on this system is" & Integer'Image (Recursion (1)));
end Test_Recursion_Depth;
| <?php
function a() {
static $i = 0;
print ++$i . "\n";
a();
}
a();
|
Translate the given Ada code snippet into PHP without altering its behavior. | with Ada.Text_IO; use Ada.Text_IO;
procedure Test_Recursion_Depth is
function Recursion (Depth : Positive) return Positive is
begin
return Recursion (Depth + 1);
exception
when Storage_Error =>
return Depth;
end Recursion;
begin
Put_Line ("Recursion depth on this system is" & Integer'Image (Recursion (1)));
end Test_Recursion_Depth;
| <?php
function a() {
static $i = 0;
print ++$i . "\n";
a();
}
a();
|
Port the following code from Arturo to PHP with equivalent syntax and logic. | recurse: function [x][
print x
recurse x+1
]
recurse 0
| <?php
function a() {
static $i = 0;
print ++$i . "\n";
a();
}
a();
|
Can you help me rewrite this code in PHP instead of Arturo, keeping it the same logically? | recurse: function [x][
print x
recurse x+1
]
recurse 0
| <?php
function a() {
static $i = 0;
print ++$i . "\n";
a();
}
a();
|
Write the same algorithm in PHP as shown in this AutoHotKey implementation. | Recurse(0)
Recurse(x)
{
TrayTip, Number, %x%
Recurse(x+1)
}
| <?php
function a() {
static $i = 0;
print ++$i . "\n";
a();
}
a();
|
Please provide an equivalent version of this AutoHotKey code in PHP. | Recurse(0)
Recurse(x)
{
TrayTip, Number, %x%
Recurse(x+1)
}
| <?php
function a() {
static $i = 0;
print ++$i . "\n";
a();
}
a();
|
Port the following code from AWK to PHP with equivalent syntax and logic. |
BEGIN {
x()
print("done")
}
function x() {
print(++n)
if (n > 999999) { return }
x()
}
| <?php
function a() {
static $i = 0;
print ++$i . "\n";
a();
}
a();
|
Convert this AWK block to PHP, preserving its control flow and logic. |
BEGIN {
x()
print("done")
}
function x() {
print(++n)
if (n > 999999) { return }
x()
}
| <?php
function a() {
static $i = 0;
print ++$i . "\n";
a();
}
a();
|
Keep all operations the same but rewrite the snippet in PHP. | PROCrecurse(1)
END
DEF PROCrecurse(depth%)
IF depth% MOD 100 = 0 PRINT TAB(0,0) depth%;
PROCrecurse(depth% + 1)
ENDPROC
| <?php
function a() {
static $i = 0;
print ++$i . "\n";
a();
}
a();
|
Change the following BBC_Basic code into PHP without altering its purpose. | PROCrecurse(1)
END
DEF PROCrecurse(depth%)
IF depth% MOD 100 = 0 PRINT TAB(0,0) depth%;
PROCrecurse(depth% + 1)
ENDPROC
| <?php
function a() {
static $i = 0;
print ++$i . "\n";
a();
}
a();
|
Translate this program into PHP but keep the logic exactly as in Clojure. | => (def *stack* 0)
=> ((fn overflow [] ((def *stack* (inc *stack*))(overflow))))
java.lang.StackOverflowError (NO_SOURCE_FILE:0)
=> *stack*
10498
| <?php
function a() {
static $i = 0;
print ++$i . "\n";
a();
}
a();
|
Convert the following code from Clojure to PHP, ensuring the logic remains intact. | => (def *stack* 0)
=> ((fn overflow [] ((def *stack* (inc *stack*))(overflow))))
java.lang.StackOverflowError (NO_SOURCE_FILE:0)
=> *stack*
10498
| <?php
function a() {
static $i = 0;
print ++$i . "\n";
a();
}
a();
|
Produce a language-to-language conversion: from Common_Lisp to PHP, same semantics. | (defun recursion-limit (x)
(if (zp x)
0
(prog2$ (cw "~x0~%" x)
(1+ (recursion-limit (1+ x))))))
| <?php
function a() {
static $i = 0;
print ++$i . "\n";
a();
}
a();
|
Transform the following Common_Lisp implementation into PHP, maintaining the same output and logic. | (defun recursion-limit (x)
(if (zp x)
0
(prog2$ (cw "~x0~%" x)
(1+ (recursion-limit (1+ x))))))
| <?php
function a() {
static $i = 0;
print ++$i . "\n";
a();
}
a();
|
Translate this program into PHP but keep the logic exactly as in D. | import std.c.stdio;
void recurse(in uint i=0) {
printf("%u ", i);
recurse(i + 1);
}
void main() {
recurse();
}
| <?php
function a() {
static $i = 0;
print ++$i . "\n";
a();
}
a();
|
Write the same algorithm in PHP as shown in this D implementation. | import std.c.stdio;
void recurse(in uint i=0) {
printf("%u ", i);
recurse(i + 1);
}
void main() {
recurse();
}
| <?php
function a() {
static $i = 0;
print ++$i . "\n";
a();
}
a();
|
Change the following Delphi code into PHP without altering its purpose. | program Project2;
uses
SysUtils;
function Recursive(Level : Integer) : Integer;
begin
try
Level := Level + 1;
Result := Recursive(Level);
except
on E: EStackOverflow do
Result := Level;
end;
end;
begin
Writeln('Recursion Level is ', Recursive(0));
Writeln('Press any key to Exit');
Readln;
end.
| <?php
function a() {
static $i = 0;
print ++$i . "\n";
a();
}
a();
|
Produce a language-to-language conversion: from Delphi to PHP, same semantics. | program Project2;
uses
SysUtils;
function Recursive(Level : Integer) : Integer;
begin
try
Level := Level + 1;
Result := Recursive(Level);
except
on E: EStackOverflow do
Result := Level;
end;
end;
begin
Writeln('Recursion Level is ', Recursive(0));
Writeln('Press any key to Exit');
Readln;
end.
| <?php
function a() {
static $i = 0;
print ++$i . "\n";
a();
}
a();
|
Generate a PHP translation of this F# snippet without changing its computational steps. | let rec recurse n =
recurse (n+1)
recurse 0
| <?php
function a() {
static $i = 0;
print ++$i . "\n";
a();
}
a();
|
Transform the following F# implementation into PHP, maintaining the same output and logic. | let rec recurse n =
recurse (n+1)
recurse 0
| <?php
function a() {
static $i = 0;
print ++$i . "\n";
a();
}
a();
|
Write the same algorithm in PHP as shown in this Factor implementation. | : recurse ( n -- n ) 1 + recurse ;
0 recurse
| <?php
function a() {
static $i = 0;
print ++$i . "\n";
a();
}
a();
|
Write a version of this Factor function in PHP with identical behavior. | : recurse ( n -- n ) 1 + recurse ;
0 recurse
| <?php
function a() {
static $i = 0;
print ++$i . "\n";
a();
}
a();
|
Convert this Forth block to PHP, preserving its control flow and logic. | : munge 1+ recurse ;
: test 0 ['] munge catch if ." Recursion limit at depth " . then ;
test
| <?php
function a() {
static $i = 0;
print ++$i . "\n";
a();
}
a();
|
Produce a functionally identical PHP code for the snippet given in Forth. | : munge 1+ recurse ;
: test 0 ['] munge catch if ." Recursion limit at depth " . then ;
test
| <?php
function a() {
static $i = 0;
print ++$i . "\n";
a();
}
a();
|
Translate the given Fortran code snippet into PHP without altering its behavior. | program recursion_depth
implicit none
call recurse (1)
contains
recursive subroutine recurse (i)
implicit none
integer, intent (in) :: i
write (*, '(i0)') i
call recurse (i + 1)
end subroutine recurse
end program recursion_depth
| <?php
function a() {
static $i = 0;
print ++$i . "\n";
a();
}
a();
|
Write the same algorithm in PHP as shown in this Fortran implementation. | program recursion_depth
implicit none
call recurse (1)
contains
recursive subroutine recurse (i)
implicit none
integer, intent (in) :: i
write (*, '(i0)') i
call recurse (i + 1)
end subroutine recurse
end program recursion_depth
| <?php
function a() {
static $i = 0;
print ++$i . "\n";
a();
}
a();
|
Generate an equivalent PHP version of this Groovy code. | def recurse;
recurse = {
try {
recurse (it + 1)
} catch (StackOverflowError e) {
return it
}
}
recurse(0)
| <?php
function a() {
static $i = 0;
print ++$i . "\n";
a();
}
a();
|
Translate this program into PHP but keep the logic exactly as in Groovy. | def recurse;
recurse = {
try {
recurse (it + 1)
} catch (StackOverflowError e) {
return it
}
}
recurse(0)
| <?php
function a() {
static $i = 0;
print ++$i . "\n";
a();
}
a();
|
Translate this program into PHP but keep the logic exactly as in Haskell. | import Debug.Trace (trace)
recurse :: Int -> Int
recurse n = trace (show n) recurse (succ n)
main :: IO ()
main = print $ recurse 1
| <?php
function a() {
static $i = 0;
print ++$i . "\n";
a();
}
a();
|
Rewrite this program in PHP while keeping its functionality equivalent to the Haskell version. | import Debug.Trace (trace)
recurse :: Int -> Int
recurse n = trace (show n) recurse (succ n)
main :: IO ()
main = print $ recurse 1
| <?php
function a() {
static $i = 0;
print ++$i . "\n";
a();
}
a();
|
Generate an equivalent PHP version of this Icon code. | procedure main()
envar := "MSTKSIZE"
write(&errout,"Program to test recursion depth - dependant on the environment variable ",envar," = ",\getenv(envar)|&null)
deepdive()
end
procedure deepdive()
static d
initial d := 0
write( d +:= 1)
deepdive()
end
| <?php
function a() {
static $i = 0;
print ++$i . "\n";
a();
}
a();
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.