Instruction stringlengths 45 106 | input_code stringlengths 1 13.7k | output_code stringlengths 1 13.7k |
|---|---|---|
Write a version of this Haskell function in Go with identical behavior. | import Data.Version
import Control.Monad
import System.Info
minGHCVersion = Version [6, 8] []
main = when (compilerName == "ghc" && compilerVersion < minGHCVersion) $
fail "Compiler too old."
| package main
import (
"debug/elf"
"debug/gosym"
"fmt"
"log"
"math"
"os"
"runtime"
)
var bloop = -3.4
func main() {
fmt.Println("task 1: verify version")
fmt.Println(" program compiled with", runtime.Version())
fmt.Println("task 2: check for presence of variable and function... |
Produce a functionally identical C code for the snippet given in J. | 6 (2!:55@:]^:>) 0 ". 1 { 9!:14''
| #if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L
#pragma error("C compiler must adhere to at least C99 for the following code.")
#else
#endif
|
Can you help me rewrite this code in C# instead of J, keeping it the same logically? | 6 (2!:55@:]^:>) 0 ". 1 { 9!:14''
| using System;
using System.Reflection;
namespace Rosetta_Introspection
{
static public class Program
{
static public int bloop = -10;
static public int bloop2 = -20;
public static void Main()
{
var asm = Assembly.GetExecutingAssembly();
var version = int.Parse(asm.ImageRuntimeVersion.Split('.')[0].Sub... |
Write a version of this J function in C++ with identical behavior. | 6 (2!:55@:]^:>) 0 ". 1 { 9!:14''
| #if !defined(__cplusplus) || __cplusplus < 201103L
#pragma error("The following code requires at least C++11.")
#else
#endif
|
Produce a language-to-language conversion: from J to Java, same semantics. | 6 (2!:55@:]^:>) 0 ". 1 { 9!:14''
| public class VersCheck {
public static void main(String[] args) {
String vers = System.getProperty("java.version");
vers = vers.substring(0,vers.indexOf('.')) + "." +
vers.substring(vers.indexOf('.')+1,vers.lastIndexOf('.'));
if(Double.parseDouble(vers) >= 1.5){
System.out.println("YAY!");
}else{
Sy... |
Translate the given J code snippet into Python without altering its behavior. | 6 (2!:55@:]^:>) 0 ". 1 { 9!:14''
|
import sys
major, minor, bugfix = sys.version_info[:3]
if major < 2:
sys.exit('Python 2 is required')
def defined(name):
return name in globals() or name in locals() or name in vars(__builtins__)
def defined2(name):
try:
eval(name)
return True
except NameError:
... |
Port the following code from J to Go with equivalent syntax and logic. | 6 (2!:55@:]^:>) 0 ". 1 { 9!:14''
| package main
import (
"debug/elf"
"debug/gosym"
"fmt"
"log"
"math"
"os"
"runtime"
)
var bloop = -3.4
func main() {
fmt.Println("task 1: verify version")
fmt.Println(" program compiled with", runtime.Version())
fmt.Println("task 2: check for presence of variable and function... |
Generate an equivalent C version of this Julia code. | @show VERSION
VERSION < v"0.4" && exit(1)
if isdefined(Base, :bloop) && !isempty(methods(abs))
@show abs(bloop)
end
a, b, c = 1, 2, 3
vars = filter(x -> eval(x) isa Integer, names(Main))
println("Integer variables: ", join(vars, ", "), ".")
println("Sum of integers in the global scope: ", sum(eval.(vars)), ".")
| #if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L
#pragma error("C compiler must adhere to at least C99 for the following code.")
#else
#endif
|
Produce a language-to-language conversion: from Julia to C#, same semantics. | @show VERSION
VERSION < v"0.4" && exit(1)
if isdefined(Base, :bloop) && !isempty(methods(abs))
@show abs(bloop)
end
a, b, c = 1, 2, 3
vars = filter(x -> eval(x) isa Integer, names(Main))
println("Integer variables: ", join(vars, ", "), ".")
println("Sum of integers in the global scope: ", sum(eval.(vars)), ".")
| using System;
using System.Reflection;
namespace Rosetta_Introspection
{
static public class Program
{
static public int bloop = -10;
static public int bloop2 = -20;
public static void Main()
{
var asm = Assembly.GetExecutingAssembly();
var version = int.Parse(asm.ImageRuntimeVersion.Split('.')[0].Sub... |
Translate this program into C++ but keep the logic exactly as in Julia. | @show VERSION
VERSION < v"0.4" && exit(1)
if isdefined(Base, :bloop) && !isempty(methods(abs))
@show abs(bloop)
end
a, b, c = 1, 2, 3
vars = filter(x -> eval(x) isa Integer, names(Main))
println("Integer variables: ", join(vars, ", "), ".")
println("Sum of integers in the global scope: ", sum(eval.(vars)), ".")
| #if !defined(__cplusplus) || __cplusplus < 201103L
#pragma error("The following code requires at least C++11.")
#else
#endif
|
Write the same code in Java as shown below in Julia. | @show VERSION
VERSION < v"0.4" && exit(1)
if isdefined(Base, :bloop) && !isempty(methods(abs))
@show abs(bloop)
end
a, b, c = 1, 2, 3
vars = filter(x -> eval(x) isa Integer, names(Main))
println("Integer variables: ", join(vars, ", "), ".")
println("Sum of integers in the global scope: ", sum(eval.(vars)), ".")
| public class VersCheck {
public static void main(String[] args) {
String vers = System.getProperty("java.version");
vers = vers.substring(0,vers.indexOf('.')) + "." +
vers.substring(vers.indexOf('.')+1,vers.lastIndexOf('.'));
if(Double.parseDouble(vers) >= 1.5){
System.out.println("YAY!");
}else{
Sy... |
Translate the given Julia code snippet into Python without altering its behavior. | @show VERSION
VERSION < v"0.4" && exit(1)
if isdefined(Base, :bloop) && !isempty(methods(abs))
@show abs(bloop)
end
a, b, c = 1, 2, 3
vars = filter(x -> eval(x) isa Integer, names(Main))
println("Integer variables: ", join(vars, ", "), ".")
println("Sum of integers in the global scope: ", sum(eval.(vars)), ".")
|
import sys
major, minor, bugfix = sys.version_info[:3]
if major < 2:
sys.exit('Python 2 is required')
def defined(name):
return name in globals() or name in locals() or name in vars(__builtins__)
def defined2(name):
try:
eval(name)
return True
except NameError:
... |
Write the same code in VB as shown below in Julia. | @show VERSION
VERSION < v"0.4" && exit(1)
if isdefined(Base, :bloop) && !isempty(methods(abs))
@show abs(bloop)
end
a, b, c = 1, 2, 3
vars = filter(x -> eval(x) isa Integer, names(Main))
println("Integer variables: ", join(vars, ", "), ".")
println("Sum of integers in the global scope: ", sum(eval.(vars)), ".")
| If Application.Version < 15 Then Exit Sub
|
Change the following Julia code into Go without altering its purpose. | @show VERSION
VERSION < v"0.4" && exit(1)
if isdefined(Base, :bloop) && !isempty(methods(abs))
@show abs(bloop)
end
a, b, c = 1, 2, 3
vars = filter(x -> eval(x) isa Integer, names(Main))
println("Integer variables: ", join(vars, ", "), ".")
println("Sum of integers in the global scope: ", sum(eval.(vars)), ".")
| package main
import (
"debug/elf"
"debug/gosym"
"fmt"
"log"
"math"
"os"
"runtime"
)
var bloop = -3.4
func main() {
fmt.Println("task 1: verify version")
fmt.Println(" program compiled with", runtime.Version())
fmt.Println("task 2: check for presence of variable and function... |
Rewrite this program in C while keeping its functionality equivalent to the Lua version. | if _VERSION:sub(5) + 0 < 5.1 then print"too old" end
if bloop and math.abs then print(math.abs(bloop)) end
| #if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L
#pragma error("C compiler must adhere to at least C99 for the following code.")
#else
#endif
|
Port the following code from Lua to C# with equivalent syntax and logic. | if _VERSION:sub(5) + 0 < 5.1 then print"too old" end
if bloop and math.abs then print(math.abs(bloop)) end
| using System;
using System.Reflection;
namespace Rosetta_Introspection
{
static public class Program
{
static public int bloop = -10;
static public int bloop2 = -20;
public static void Main()
{
var asm = Assembly.GetExecutingAssembly();
var version = int.Parse(asm.ImageRuntimeVersion.Split('.')[0].Sub... |
Convert the following code from Lua to C++, ensuring the logic remains intact. | if _VERSION:sub(5) + 0 < 5.1 then print"too old" end
if bloop and math.abs then print(math.abs(bloop)) end
| #if !defined(__cplusplus) || __cplusplus < 201103L
#pragma error("The following code requires at least C++11.")
#else
#endif
|
Please provide an equivalent version of this Lua code in Java. | if _VERSION:sub(5) + 0 < 5.1 then print"too old" end
if bloop and math.abs then print(math.abs(bloop)) end
| public class VersCheck {
public static void main(String[] args) {
String vers = System.getProperty("java.version");
vers = vers.substring(0,vers.indexOf('.')) + "." +
vers.substring(vers.indexOf('.')+1,vers.lastIndexOf('.'));
if(Double.parseDouble(vers) >= 1.5){
System.out.println("YAY!");
}else{
Sy... |
Convert this Lua snippet to Python and keep its semantics consistent. | if _VERSION:sub(5) + 0 < 5.1 then print"too old" end
if bloop and math.abs then print(math.abs(bloop)) end
|
import sys
major, minor, bugfix = sys.version_info[:3]
if major < 2:
sys.exit('Python 2 is required')
def defined(name):
return name in globals() or name in locals() or name in vars(__builtins__)
def defined2(name):
try:
eval(name)
return True
except NameError:
... |
Change the following Lua code into VB without altering its purpose. | if _VERSION:sub(5) + 0 < 5.1 then print"too old" end
if bloop and math.abs then print(math.abs(bloop)) end
| If Application.Version < 15 Then Exit Sub
|
Preserve the algorithm and functionality while converting the code from Lua to Go. | if _VERSION:sub(5) + 0 < 5.1 then print"too old" end
if bloop and math.abs then print(math.abs(bloop)) end
| package main
import (
"debug/elf"
"debug/gosym"
"fmt"
"log"
"math"
"os"
"runtime"
)
var bloop = -3.4
func main() {
fmt.Println("task 1: verify version")
fmt.Println(" program compiled with", runtime.Version())
fmt.Println("task 2: check for presence of variable and function... |
Write the same code in C as shown below in Mathematica. | If[$VersionNumber < 8, Quit[]]
If[NameQ["bloop"] && NameQ["Abs"],
Print[Abs[bloop]]]
| #if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L
#pragma error("C compiler must adhere to at least C99 for the following code.")
#else
#endif
|
Can you help me rewrite this code in C# instead of Mathematica, keeping it the same logically? | If[$VersionNumber < 8, Quit[]]
If[NameQ["bloop"] && NameQ["Abs"],
Print[Abs[bloop]]]
| using System;
using System.Reflection;
namespace Rosetta_Introspection
{
static public class Program
{
static public int bloop = -10;
static public int bloop2 = -20;
public static void Main()
{
var asm = Assembly.GetExecutingAssembly();
var version = int.Parse(asm.ImageRuntimeVersion.Split('.')[0].Sub... |
Can you help me rewrite this code in C++ instead of Mathematica, keeping it the same logically? | If[$VersionNumber < 8, Quit[]]
If[NameQ["bloop"] && NameQ["Abs"],
Print[Abs[bloop]]]
| #if !defined(__cplusplus) || __cplusplus < 201103L
#pragma error("The following code requires at least C++11.")
#else
#endif
|
Write a version of this Mathematica function in Java with identical behavior. | If[$VersionNumber < 8, Quit[]]
If[NameQ["bloop"] && NameQ["Abs"],
Print[Abs[bloop]]]
| public class VersCheck {
public static void main(String[] args) {
String vers = System.getProperty("java.version");
vers = vers.substring(0,vers.indexOf('.')) + "." +
vers.substring(vers.indexOf('.')+1,vers.lastIndexOf('.'));
if(Double.parseDouble(vers) >= 1.5){
System.out.println("YAY!");
}else{
Sy... |
Rewrite this program in Python while keeping its functionality equivalent to the Mathematica version. | If[$VersionNumber < 8, Quit[]]
If[NameQ["bloop"] && NameQ["Abs"],
Print[Abs[bloop]]]
|
import sys
major, minor, bugfix = sys.version_info[:3]
if major < 2:
sys.exit('Python 2 is required')
def defined(name):
return name in globals() or name in locals() or name in vars(__builtins__)
def defined2(name):
try:
eval(name)
return True
except NameError:
... |
Transform the following Mathematica implementation into VB, maintaining the same output and logic. | If[$VersionNumber < 8, Quit[]]
If[NameQ["bloop"] && NameQ["Abs"],
Print[Abs[bloop]]]
| If Application.Version < 15 Then Exit Sub
|
Produce a language-to-language conversion: from Mathematica to Go, same semantics. | If[$VersionNumber < 8, Quit[]]
If[NameQ["bloop"] && NameQ["Abs"],
Print[Abs[bloop]]]
| package main
import (
"debug/elf"
"debug/gosym"
"fmt"
"log"
"math"
"os"
"runtime"
)
var bloop = -3.4
func main() {
fmt.Println("task 1: verify version")
fmt.Println(" program compiled with", runtime.Version())
fmt.Println("task 2: check for presence of variable and function... |
Write a version of this MATLAB function in C with identical behavior. |
v = version;
v(v=='.')=' ';
v = str2num(v);
if v(2)>10; v(2) = v(2)/10; end;
ver = v(1)+v(2)/10;
if exist('OCTAVE_VERSION','builtin')
if ver < 3.0,
exit
end;
else
if ver < 7.0,
exit
end;
end
if exist('bloob','var') && any(exist('abs... | #if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L
#pragma error("C compiler must adhere to at least C99 for the following code.")
#else
#endif
|
Transform the following MATLAB implementation into C#, maintaining the same output and logic. |
v = version;
v(v=='.')=' ';
v = str2num(v);
if v(2)>10; v(2) = v(2)/10; end;
ver = v(1)+v(2)/10;
if exist('OCTAVE_VERSION','builtin')
if ver < 3.0,
exit
end;
else
if ver < 7.0,
exit
end;
end
if exist('bloob','var') && any(exist('abs... | using System;
using System.Reflection;
namespace Rosetta_Introspection
{
static public class Program
{
static public int bloop = -10;
static public int bloop2 = -20;
public static void Main()
{
var asm = Assembly.GetExecutingAssembly();
var version = int.Parse(asm.ImageRuntimeVersion.Split('.')[0].Sub... |
Write a version of this MATLAB function in C++ with identical behavior. |
v = version;
v(v=='.')=' ';
v = str2num(v);
if v(2)>10; v(2) = v(2)/10; end;
ver = v(1)+v(2)/10;
if exist('OCTAVE_VERSION','builtin')
if ver < 3.0,
exit
end;
else
if ver < 7.0,
exit
end;
end
if exist('bloob','var') && any(exist('abs... | #if !defined(__cplusplus) || __cplusplus < 201103L
#pragma error("The following code requires at least C++11.")
#else
#endif
|
Write a version of this MATLAB function in Java with identical behavior. |
v = version;
v(v=='.')=' ';
v = str2num(v);
if v(2)>10; v(2) = v(2)/10; end;
ver = v(1)+v(2)/10;
if exist('OCTAVE_VERSION','builtin')
if ver < 3.0,
exit
end;
else
if ver < 7.0,
exit
end;
end
if exist('bloob','var') && any(exist('abs... | public class VersCheck {
public static void main(String[] args) {
String vers = System.getProperty("java.version");
vers = vers.substring(0,vers.indexOf('.')) + "." +
vers.substring(vers.indexOf('.')+1,vers.lastIndexOf('.'));
if(Double.parseDouble(vers) >= 1.5){
System.out.println("YAY!");
}else{
Sy... |
Write a version of this MATLAB function in Python with identical behavior. |
v = version;
v(v=='.')=' ';
v = str2num(v);
if v(2)>10; v(2) = v(2)/10; end;
ver = v(1)+v(2)/10;
if exist('OCTAVE_VERSION','builtin')
if ver < 3.0,
exit
end;
else
if ver < 7.0,
exit
end;
end
if exist('bloob','var') && any(exist('abs... |
import sys
major, minor, bugfix = sys.version_info[:3]
if major < 2:
sys.exit('Python 2 is required')
def defined(name):
return name in globals() or name in locals() or name in vars(__builtins__)
def defined2(name):
try:
eval(name)
return True
except NameError:
... |
Write a version of this MATLAB function in VB with identical behavior. |
v = version;
v(v=='.')=' ';
v = str2num(v);
if v(2)>10; v(2) = v(2)/10; end;
ver = v(1)+v(2)/10;
if exist('OCTAVE_VERSION','builtin')
if ver < 3.0,
exit
end;
else
if ver < 7.0,
exit
end;
end
if exist('bloob','var') && any(exist('abs... | If Application.Version < 15 Then Exit Sub
|
Transform the following MATLAB implementation into Go, maintaining the same output and logic. |
v = version;
v(v=='.')=' ';
v = str2num(v);
if v(2)>10; v(2) = v(2)/10; end;
ver = v(1)+v(2)/10;
if exist('OCTAVE_VERSION','builtin')
if ver < 3.0,
exit
end;
else
if ver < 7.0,
exit
end;
end
if exist('bloob','var') && any(exist('abs... | package main
import (
"debug/elf"
"debug/gosym"
"fmt"
"log"
"math"
"os"
"runtime"
)
var bloop = -3.4
func main() {
fmt.Println("task 1: verify version")
fmt.Println(" program compiled with", runtime.Version())
fmt.Println("task 2: check for presence of variable and function... |
Port the provided Nim code into C while preserving the original functionality. | when NimVersion < "1.2":
error "This compiler is too old"
assert NimVersion >= "1.4", "This compiler is too old."
var bloop = -12
when compiles abs(bloop):
echo abs(bloop)
| #if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L
#pragma error("C compiler must adhere to at least C99 for the following code.")
#else
#endif
|
Generate a C# translation of this Nim snippet without changing its computational steps. | when NimVersion < "1.2":
error "This compiler is too old"
assert NimVersion >= "1.4", "This compiler is too old."
var bloop = -12
when compiles abs(bloop):
echo abs(bloop)
| using System;
using System.Reflection;
namespace Rosetta_Introspection
{
static public class Program
{
static public int bloop = -10;
static public int bloop2 = -20;
public static void Main()
{
var asm = Assembly.GetExecutingAssembly();
var version = int.Parse(asm.ImageRuntimeVersion.Split('.')[0].Sub... |
Change the following Nim code into C++ without altering its purpose. | when NimVersion < "1.2":
error "This compiler is too old"
assert NimVersion >= "1.4", "This compiler is too old."
var bloop = -12
when compiles abs(bloop):
echo abs(bloop)
| #if !defined(__cplusplus) || __cplusplus < 201103L
#pragma error("The following code requires at least C++11.")
#else
#endif
|
Write the same code in Java as shown below in Nim. | when NimVersion < "1.2":
error "This compiler is too old"
assert NimVersion >= "1.4", "This compiler is too old."
var bloop = -12
when compiles abs(bloop):
echo abs(bloop)
| public class VersCheck {
public static void main(String[] args) {
String vers = System.getProperty("java.version");
vers = vers.substring(0,vers.indexOf('.')) + "." +
vers.substring(vers.indexOf('.')+1,vers.lastIndexOf('.'));
if(Double.parseDouble(vers) >= 1.5){
System.out.println("YAY!");
}else{
Sy... |
Write the same algorithm in Python as shown in this Nim implementation. | when NimVersion < "1.2":
error "This compiler is too old"
assert NimVersion >= "1.4", "This compiler is too old."
var bloop = -12
when compiles abs(bloop):
echo abs(bloop)
|
import sys
major, minor, bugfix = sys.version_info[:3]
if major < 2:
sys.exit('Python 2 is required')
def defined(name):
return name in globals() or name in locals() or name in vars(__builtins__)
def defined2(name):
try:
eval(name)
return True
except NameError:
... |
Transform the following Nim implementation into VB, maintaining the same output and logic. | when NimVersion < "1.2":
error "This compiler is too old"
assert NimVersion >= "1.4", "This compiler is too old."
var bloop = -12
when compiles abs(bloop):
echo abs(bloop)
| If Application.Version < 15 Then Exit Sub
|
Generate a Go translation of this Nim snippet without changing its computational steps. | when NimVersion < "1.2":
error "This compiler is too old"
assert NimVersion >= "1.4", "This compiler is too old."
var bloop = -12
when compiles abs(bloop):
echo abs(bloop)
| package main
import (
"debug/elf"
"debug/gosym"
"fmt"
"log"
"math"
"os"
"runtime"
)
var bloop = -3.4
func main() {
fmt.Println("task 1: verify version")
fmt.Println(" program compiled with", runtime.Version())
fmt.Println("task 2: check for presence of variable and function... |
Rewrite this program in C while keeping its functionality equivalent to the OCaml version. | # Sys.ocaml_version;;
- : string = "3.10.2"
| #if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L
#pragma error("C compiler must adhere to at least C99 for the following code.")
#else
#endif
|
Can you help me rewrite this code in C# instead of OCaml, keeping it the same logically? | # Sys.ocaml_version;;
- : string = "3.10.2"
| using System;
using System.Reflection;
namespace Rosetta_Introspection
{
static public class Program
{
static public int bloop = -10;
static public int bloop2 = -20;
public static void Main()
{
var asm = Assembly.GetExecutingAssembly();
var version = int.Parse(asm.ImageRuntimeVersion.Split('.')[0].Sub... |
Translate this program into C++ but keep the logic exactly as in OCaml. | # Sys.ocaml_version;;
- : string = "3.10.2"
| #if !defined(__cplusplus) || __cplusplus < 201103L
#pragma error("The following code requires at least C++11.")
#else
#endif
|
Generate a Java translation of this OCaml snippet without changing its computational steps. | # Sys.ocaml_version;;
- : string = "3.10.2"
| public class VersCheck {
public static void main(String[] args) {
String vers = System.getProperty("java.version");
vers = vers.substring(0,vers.indexOf('.')) + "." +
vers.substring(vers.indexOf('.')+1,vers.lastIndexOf('.'));
if(Double.parseDouble(vers) >= 1.5){
System.out.println("YAY!");
}else{
Sy... |
Rewrite this program in Python while keeping its functionality equivalent to the OCaml version. | # Sys.ocaml_version;;
- : string = "3.10.2"
|
import sys
major, minor, bugfix = sys.version_info[:3]
if major < 2:
sys.exit('Python 2 is required')
def defined(name):
return name in globals() or name in locals() or name in vars(__builtins__)
def defined2(name):
try:
eval(name)
return True
except NameError:
... |
Transform the following OCaml implementation into Go, maintaining the same output and logic. | # Sys.ocaml_version;;
- : string = "3.10.2"
| package main
import (
"debug/elf"
"debug/gosym"
"fmt"
"log"
"math"
"os"
"runtime"
)
var bloop = -3.4
func main() {
fmt.Println("task 1: verify version")
fmt.Println(" program compiled with", runtime.Version())
fmt.Println("task 2: check for presence of variable and function... |
Translate the given Perl code snippet into C without altering its behavior. | require v5.6.1;
require 5.6.1;
require 5.006_001;
| #if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L
#pragma error("C compiler must adhere to at least C99 for the following code.")
#else
#endif
|
Preserve the algorithm and functionality while converting the code from Perl to C#. | require v5.6.1;
require 5.6.1;
require 5.006_001;
| using System;
using System.Reflection;
namespace Rosetta_Introspection
{
static public class Program
{
static public int bloop = -10;
static public int bloop2 = -20;
public static void Main()
{
var asm = Assembly.GetExecutingAssembly();
var version = int.Parse(asm.ImageRuntimeVersion.Split('.')[0].Sub... |
Convert the following code from Perl to C++, ensuring the logic remains intact. | require v5.6.1;
require 5.6.1;
require 5.006_001;
| #if !defined(__cplusplus) || __cplusplus < 201103L
#pragma error("The following code requires at least C++11.")
#else
#endif
|
Translate the given Perl code snippet into Java without altering its behavior. | require v5.6.1;
require 5.6.1;
require 5.006_001;
| public class VersCheck {
public static void main(String[] args) {
String vers = System.getProperty("java.version");
vers = vers.substring(0,vers.indexOf('.')) + "." +
vers.substring(vers.indexOf('.')+1,vers.lastIndexOf('.'));
if(Double.parseDouble(vers) >= 1.5){
System.out.println("YAY!");
}else{
Sy... |
Write the same code in Python as shown below in Perl. | require v5.6.1;
require 5.6.1;
require 5.006_001;
|
import sys
major, minor, bugfix = sys.version_info[:3]
if major < 2:
sys.exit('Python 2 is required')
def defined(name):
return name in globals() or name in locals() or name in vars(__builtins__)
def defined2(name):
try:
eval(name)
return True
except NameError:
... |
Change the programming language of this snippet from Perl to VB without modifying what it does. | require v5.6.1;
require 5.6.1;
require 5.006_001;
| If Application.Version < 15 Then Exit Sub
|
Port the provided Perl code into Go while preserving the original functionality. | require v5.6.1;
require 5.6.1;
require 5.006_001;
| package main
import (
"debug/elf"
"debug/gosym"
"fmt"
"log"
"math"
"os"
"runtime"
)
var bloop = -3.4
func main() {
fmt.Println("task 1: verify version")
fmt.Println(" program compiled with", runtime.Version())
fmt.Println("task 2: check for presence of variable and function... |
Convert this PowerShell snippet to C and keep its semantics consistent. |
if ($PSVersionTable['PSVersion'] -lt '2.0') {
exit
}
if ((Test-Path Variable:bloop) -and ([Math]::Abs)) {
[Math]::Abs($bloop)
}
Get-Variable -Scope global `
| Where-Object { $_.Value -is [int] } `
| Measure-Object -Sum Value `
| Select-Object Count,Sum
| #if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L
#pragma error("C compiler must adhere to at least C99 for the following code.")
#else
#endif
|
Maintain the same structure and functionality when rewriting this code in C#. |
if ($PSVersionTable['PSVersion'] -lt '2.0') {
exit
}
if ((Test-Path Variable:bloop) -and ([Math]::Abs)) {
[Math]::Abs($bloop)
}
Get-Variable -Scope global `
| Where-Object { $_.Value -is [int] } `
| Measure-Object -Sum Value `
| Select-Object Count,Sum
| using System;
using System.Reflection;
namespace Rosetta_Introspection
{
static public class Program
{
static public int bloop = -10;
static public int bloop2 = -20;
public static void Main()
{
var asm = Assembly.GetExecutingAssembly();
var version = int.Parse(asm.ImageRuntimeVersion.Split('.')[0].Sub... |
Rewrite this program in C++ while keeping its functionality equivalent to the PowerShell version. |
if ($PSVersionTable['PSVersion'] -lt '2.0') {
exit
}
if ((Test-Path Variable:bloop) -and ([Math]::Abs)) {
[Math]::Abs($bloop)
}
Get-Variable -Scope global `
| Where-Object { $_.Value -is [int] } `
| Measure-Object -Sum Value `
| Select-Object Count,Sum
| #if !defined(__cplusplus) || __cplusplus < 201103L
#pragma error("The following code requires at least C++11.")
#else
#endif
|
Port the provided PowerShell code into Java while preserving the original functionality. |
if ($PSVersionTable['PSVersion'] -lt '2.0') {
exit
}
if ((Test-Path Variable:bloop) -and ([Math]::Abs)) {
[Math]::Abs($bloop)
}
Get-Variable -Scope global `
| Where-Object { $_.Value -is [int] } `
| Measure-Object -Sum Value `
| Select-Object Count,Sum
| public class VersCheck {
public static void main(String[] args) {
String vers = System.getProperty("java.version");
vers = vers.substring(0,vers.indexOf('.')) + "." +
vers.substring(vers.indexOf('.')+1,vers.lastIndexOf('.'));
if(Double.parseDouble(vers) >= 1.5){
System.out.println("YAY!");
}else{
Sy... |
Write the same code in Python as shown below in PowerShell. |
if ($PSVersionTable['PSVersion'] -lt '2.0') {
exit
}
if ((Test-Path Variable:bloop) -and ([Math]::Abs)) {
[Math]::Abs($bloop)
}
Get-Variable -Scope global `
| Where-Object { $_.Value -is [int] } `
| Measure-Object -Sum Value `
| Select-Object Count,Sum
|
import sys
major, minor, bugfix = sys.version_info[:3]
if major < 2:
sys.exit('Python 2 is required')
def defined(name):
return name in globals() or name in locals() or name in vars(__builtins__)
def defined2(name):
try:
eval(name)
return True
except NameError:
... |
Translate this program into VB but keep the logic exactly as in PowerShell. |
if ($PSVersionTable['PSVersion'] -lt '2.0') {
exit
}
if ((Test-Path Variable:bloop) -and ([Math]::Abs)) {
[Math]::Abs($bloop)
}
Get-Variable -Scope global `
| Where-Object { $_.Value -is [int] } `
| Measure-Object -Sum Value `
| Select-Object Count,Sum
| If Application.Version < 15 Then Exit Sub
|
Ensure the translated Go code behaves exactly like the original PowerShell snippet. |
if ($PSVersionTable['PSVersion'] -lt '2.0') {
exit
}
if ((Test-Path Variable:bloop) -and ([Math]::Abs)) {
[Math]::Abs($bloop)
}
Get-Variable -Scope global `
| Where-Object { $_.Value -is [int] } `
| Measure-Object -Sum Value `
| Select-Object Count,Sum
| package main
import (
"debug/elf"
"debug/gosym"
"fmt"
"log"
"math"
"os"
"runtime"
)
var bloop = -3.4
func main() {
fmt.Println("task 1: verify version")
fmt.Println(" program compiled with", runtime.Version())
fmt.Println("task 2: check for presence of variable and function... |
Write the same algorithm in C as shown in this R implementation. | if(getRversion() < "2.14.1")
{
warning("Your version of R is older than 2.14.1")
q()
}
| #if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L
#pragma error("C compiler must adhere to at least C99 for the following code.")
#else
#endif
|
Convert this R snippet to C# and keep its semantics consistent. | if(getRversion() < "2.14.1")
{
warning("Your version of R is older than 2.14.1")
q()
}
| using System;
using System.Reflection;
namespace Rosetta_Introspection
{
static public class Program
{
static public int bloop = -10;
static public int bloop2 = -20;
public static void Main()
{
var asm = Assembly.GetExecutingAssembly();
var version = int.Parse(asm.ImageRuntimeVersion.Split('.')[0].Sub... |
Produce a language-to-language conversion: from R to C++, same semantics. | if(getRversion() < "2.14.1")
{
warning("Your version of R is older than 2.14.1")
q()
}
| #if !defined(__cplusplus) || __cplusplus < 201103L
#pragma error("The following code requires at least C++11.")
#else
#endif
|
Change the programming language of this snippet from R to Java without modifying what it does. | if(getRversion() < "2.14.1")
{
warning("Your version of R is older than 2.14.1")
q()
}
| public class VersCheck {
public static void main(String[] args) {
String vers = System.getProperty("java.version");
vers = vers.substring(0,vers.indexOf('.')) + "." +
vers.substring(vers.indexOf('.')+1,vers.lastIndexOf('.'));
if(Double.parseDouble(vers) >= 1.5){
System.out.println("YAY!");
}else{
Sy... |
Translate this program into Python but keep the logic exactly as in R. | if(getRversion() < "2.14.1")
{
warning("Your version of R is older than 2.14.1")
q()
}
|
import sys
major, minor, bugfix = sys.version_info[:3]
if major < 2:
sys.exit('Python 2 is required')
def defined(name):
return name in globals() or name in locals() or name in vars(__builtins__)
def defined2(name):
try:
eval(name)
return True
except NameError:
... |
Translate the given R code snippet into VB without altering its behavior. | if(getRversion() < "2.14.1")
{
warning("Your version of R is older than 2.14.1")
q()
}
| If Application.Version < 15 Then Exit Sub
|
Rewrite the snippet below in Go so it works the same as the original R code. | if(getRversion() < "2.14.1")
{
warning("Your version of R is older than 2.14.1")
q()
}
| package main
import (
"debug/elf"
"debug/gosym"
"fmt"
"log"
"math"
"os"
"runtime"
)
var bloop = -3.4
func main() {
fmt.Println("task 1: verify version")
fmt.Println(" program compiled with", runtime.Version())
fmt.Println("task 2: check for presence of variable and function... |
Convert this Racket block to C, preserving its control flow and logic. | #lang racket
(unless (string<=? "5.3" (version)) (error "ancient version"))
| #if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L
#pragma error("C compiler must adhere to at least C99 for the following code.")
#else
#endif
|
Rewrite this program in C# while keeping its functionality equivalent to the Racket version. | #lang racket
(unless (string<=? "5.3" (version)) (error "ancient version"))
| using System;
using System.Reflection;
namespace Rosetta_Introspection
{
static public class Program
{
static public int bloop = -10;
static public int bloop2 = -20;
public static void Main()
{
var asm = Assembly.GetExecutingAssembly();
var version = int.Parse(asm.ImageRuntimeVersion.Split('.')[0].Sub... |
Port the following code from Racket to C++ with equivalent syntax and logic. | #lang racket
(unless (string<=? "5.3" (version)) (error "ancient version"))
| #if !defined(__cplusplus) || __cplusplus < 201103L
#pragma error("The following code requires at least C++11.")
#else
#endif
|
Change the programming language of this snippet from Racket to Java without modifying what it does. | #lang racket
(unless (string<=? "5.3" (version)) (error "ancient version"))
| public class VersCheck {
public static void main(String[] args) {
String vers = System.getProperty("java.version");
vers = vers.substring(0,vers.indexOf('.')) + "." +
vers.substring(vers.indexOf('.')+1,vers.lastIndexOf('.'));
if(Double.parseDouble(vers) >= 1.5){
System.out.println("YAY!");
}else{
Sy... |
Translate this program into Python but keep the logic exactly as in Racket. | #lang racket
(unless (string<=? "5.3" (version)) (error "ancient version"))
|
import sys
major, minor, bugfix = sys.version_info[:3]
if major < 2:
sys.exit('Python 2 is required')
def defined(name):
return name in globals() or name in locals() or name in vars(__builtins__)
def defined2(name):
try:
eval(name)
return True
except NameError:
... |
Rewrite this program in Go while keeping its functionality equivalent to the Racket version. | #lang racket
(unless (string<=? "5.3" (version)) (error "ancient version"))
| package main
import (
"debug/elf"
"debug/gosym"
"fmt"
"log"
"math"
"os"
"runtime"
)
var bloop = -3.4
func main() {
fmt.Println("task 1: verify version")
fmt.Println(" program compiled with", runtime.Version())
fmt.Println("task 2: check for presence of variable and function... |
Maintain the same structure and functionality when rewriting this code in C. |
options replace format comments java crossref symbols binary
runSample(arg)
return
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
method runSample(arg) private static
parse arg minVersion .
if minVersion = '' then minVersion = 2.0
parse version lang ver bdate
if ver < minVer... | #if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L
#pragma error("C compiler must adhere to at least C99 for the following code.")
#else
#endif
|
Produce a language-to-language conversion: from REXX to C#, same semantics. |
options replace format comments java crossref symbols binary
runSample(arg)
return
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
method runSample(arg) private static
parse arg minVersion .
if minVersion = '' then minVersion = 2.0
parse version lang ver bdate
if ver < minVer... | using System;
using System.Reflection;
namespace Rosetta_Introspection
{
static public class Program
{
static public int bloop = -10;
static public int bloop2 = -20;
public static void Main()
{
var asm = Assembly.GetExecutingAssembly();
var version = int.Parse(asm.ImageRuntimeVersion.Split('.')[0].Sub... |
Produce a language-to-language conversion: from REXX to C++, same semantics. |
options replace format comments java crossref symbols binary
runSample(arg)
return
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
method runSample(arg) private static
parse arg minVersion .
if minVersion = '' then minVersion = 2.0
parse version lang ver bdate
if ver < minVer... | #if !defined(__cplusplus) || __cplusplus < 201103L
#pragma error("The following code requires at least C++11.")
#else
#endif
|
Preserve the algorithm and functionality while converting the code from REXX to Java. |
options replace format comments java crossref symbols binary
runSample(arg)
return
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
method runSample(arg) private static
parse arg minVersion .
if minVersion = '' then minVersion = 2.0
parse version lang ver bdate
if ver < minVer... | public class VersCheck {
public static void main(String[] args) {
String vers = System.getProperty("java.version");
vers = vers.substring(0,vers.indexOf('.')) + "." +
vers.substring(vers.indexOf('.')+1,vers.lastIndexOf('.'));
if(Double.parseDouble(vers) >= 1.5){
System.out.println("YAY!");
}else{
Sy... |
Change the following REXX code into Python without altering its purpose. |
options replace format comments java crossref symbols binary
runSample(arg)
return
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
method runSample(arg) private static
parse arg minVersion .
if minVersion = '' then minVersion = 2.0
parse version lang ver bdate
if ver < minVer... |
import sys
major, minor, bugfix = sys.version_info[:3]
if major < 2:
sys.exit('Python 2 is required')
def defined(name):
return name in globals() or name in locals() or name in vars(__builtins__)
def defined2(name):
try:
eval(name)
return True
except NameError:
... |
Rewrite the snippet below in VB so it works the same as the original REXX code. |
options replace format comments java crossref symbols binary
runSample(arg)
return
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
method runSample(arg) private static
parse arg minVersion .
if minVersion = '' then minVersion = 2.0
parse version lang ver bdate
if ver < minVer... | If Application.Version < 15 Then Exit Sub
|
Convert the following code from REXX to Go, ensuring the logic remains intact. |
options replace format comments java crossref symbols binary
runSample(arg)
return
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
method runSample(arg) private static
parse arg minVersion .
if minVersion = '' then minVersion = 2.0
parse version lang ver bdate
if ver < minVer... | package main
import (
"debug/elf"
"debug/gosym"
"fmt"
"log"
"math"
"os"
"runtime"
)
var bloop = -3.4
func main() {
fmt.Println("task 1: verify version")
fmt.Println(" program compiled with", runtime.Version())
fmt.Println("task 2: check for presence of variable and function... |
Rewrite the snippet below in C so it works the same as the original Ruby code. | exit if RUBY_VERSION < '1.8.6'
puts bloop.abs if defined?(bloop) and bloop.respond_to?(:abs)
| #if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L
#pragma error("C compiler must adhere to at least C99 for the following code.")
#else
#endif
|
Translate this program into C# but keep the logic exactly as in Ruby. | exit if RUBY_VERSION < '1.8.6'
puts bloop.abs if defined?(bloop) and bloop.respond_to?(:abs)
| using System;
using System.Reflection;
namespace Rosetta_Introspection
{
static public class Program
{
static public int bloop = -10;
static public int bloop2 = -20;
public static void Main()
{
var asm = Assembly.GetExecutingAssembly();
var version = int.Parse(asm.ImageRuntimeVersion.Split('.')[0].Sub... |
Write the same algorithm in C++ as shown in this Ruby implementation. | exit if RUBY_VERSION < '1.8.6'
puts bloop.abs if defined?(bloop) and bloop.respond_to?(:abs)
| #if !defined(__cplusplus) || __cplusplus < 201103L
#pragma error("The following code requires at least C++11.")
#else
#endif
|
Transform the following Ruby implementation into Java, maintaining the same output and logic. | exit if RUBY_VERSION < '1.8.6'
puts bloop.abs if defined?(bloop) and bloop.respond_to?(:abs)
| public class VersCheck {
public static void main(String[] args) {
String vers = System.getProperty("java.version");
vers = vers.substring(0,vers.indexOf('.')) + "." +
vers.substring(vers.indexOf('.')+1,vers.lastIndexOf('.'));
if(Double.parseDouble(vers) >= 1.5){
System.out.println("YAY!");
}else{
Sy... |
Port the provided Ruby code into Python while preserving the original functionality. | exit if RUBY_VERSION < '1.8.6'
puts bloop.abs if defined?(bloop) and bloop.respond_to?(:abs)
|
import sys
major, minor, bugfix = sys.version_info[:3]
if major < 2:
sys.exit('Python 2 is required')
def defined(name):
return name in globals() or name in locals() or name in vars(__builtins__)
def defined2(name):
try:
eval(name)
return True
except NameError:
... |
Ensure the translated VB code behaves exactly like the original Ruby snippet. | exit if RUBY_VERSION < '1.8.6'
puts bloop.abs if defined?(bloop) and bloop.respond_to?(:abs)
| If Application.Version < 15 Then Exit Sub
|
Port the following code from Ruby to Go with equivalent syntax and logic. | exit if RUBY_VERSION < '1.8.6'
puts bloop.abs if defined?(bloop) and bloop.respond_to?(:abs)
| package main
import (
"debug/elf"
"debug/gosym"
"fmt"
"log"
"math"
"os"
"runtime"
)
var bloop = -3.4
func main() {
fmt.Println("task 1: verify version")
fmt.Println(" program compiled with", runtime.Version())
fmt.Println("task 2: check for presence of variable and function... |
Keep all operations the same but rewrite the snippet in C. |
import java.lang.reflect.Method
val bloop = -3
val i = 4
val j = 5
val k = 6
fun main(args: Array<String>) {
val version = System.getProperty("java.version")
if (version >= "1.6") println("The current JVM version is $version")
else println("Must use version 1.6 or later")
val topLe... | #if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L
#pragma error("C compiler must adhere to at least C99 for the following code.")
#else
#endif
|
Write the same code in C# as shown below in Scala. |
import java.lang.reflect.Method
val bloop = -3
val i = 4
val j = 5
val k = 6
fun main(args: Array<String>) {
val version = System.getProperty("java.version")
if (version >= "1.6") println("The current JVM version is $version")
else println("Must use version 1.6 or later")
val topLe... | using System;
using System.Reflection;
namespace Rosetta_Introspection
{
static public class Program
{
static public int bloop = -10;
static public int bloop2 = -20;
public static void Main()
{
var asm = Assembly.GetExecutingAssembly();
var version = int.Parse(asm.ImageRuntimeVersion.Split('.')[0].Sub... |
Preserve the algorithm and functionality while converting the code from Scala to C++. |
import java.lang.reflect.Method
val bloop = -3
val i = 4
val j = 5
val k = 6
fun main(args: Array<String>) {
val version = System.getProperty("java.version")
if (version >= "1.6") println("The current JVM version is $version")
else println("Must use version 1.6 or later")
val topLe... | #if !defined(__cplusplus) || __cplusplus < 201103L
#pragma error("The following code requires at least C++11.")
#else
#endif
|
Convert this Scala block to Java, preserving its control flow and logic. |
import java.lang.reflect.Method
val bloop = -3
val i = 4
val j = 5
val k = 6
fun main(args: Array<String>) {
val version = System.getProperty("java.version")
if (version >= "1.6") println("The current JVM version is $version")
else println("Must use version 1.6 or later")
val topLe... | public class VersCheck {
public static void main(String[] args) {
String vers = System.getProperty("java.version");
vers = vers.substring(0,vers.indexOf('.')) + "." +
vers.substring(vers.indexOf('.')+1,vers.lastIndexOf('.'));
if(Double.parseDouble(vers) >= 1.5){
System.out.println("YAY!");
}else{
Sy... |
Ensure the translated Python code behaves exactly like the original Scala snippet. |
import java.lang.reflect.Method
val bloop = -3
val i = 4
val j = 5
val k = 6
fun main(args: Array<String>) {
val version = System.getProperty("java.version")
if (version >= "1.6") println("The current JVM version is $version")
else println("Must use version 1.6 or later")
val topLe... |
import sys
major, minor, bugfix = sys.version_info[:3]
if major < 2:
sys.exit('Python 2 is required')
def defined(name):
return name in globals() or name in locals() or name in vars(__builtins__)
def defined2(name):
try:
eval(name)
return True
except NameError:
... |
Write a version of this Scala function in VB with identical behavior. |
import java.lang.reflect.Method
val bloop = -3
val i = 4
val j = 5
val k = 6
fun main(args: Array<String>) {
val version = System.getProperty("java.version")
if (version >= "1.6") println("The current JVM version is $version")
else println("Must use version 1.6 or later")
val topLe... | If Application.Version < 15 Then Exit Sub
|
Keep all operations the same but rewrite the snippet in Go. |
import java.lang.reflect.Method
val bloop = -3
val i = 4
val j = 5
val k = 6
fun main(args: Array<String>) {
val version = System.getProperty("java.version")
if (version >= "1.6") println("The current JVM version is $version")
else println("Must use version 1.6 or later")
val topLe... | package main
import (
"debug/elf"
"debug/gosym"
"fmt"
"log"
"math"
"os"
"runtime"
)
var bloop = -3.4
func main() {
fmt.Println("task 1: verify version")
fmt.Println(" program compiled with", runtime.Version())
fmt.Println("task 2: check for presence of variable and function... |
Change the following Tcl code into C without altering its purpose. | package require Tcl 8.4 ;
if {[info exists bloop] && [llength [info functions abs]]} {
puts [expr abs($bloop)]
}
| #if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L
#pragma error("C compiler must adhere to at least C99 for the following code.")
#else
#endif
|
Maintain the same structure and functionality when rewriting this code in C#. | package require Tcl 8.4 ;
if {[info exists bloop] && [llength [info functions abs]]} {
puts [expr abs($bloop)]
}
| using System;
using System.Reflection;
namespace Rosetta_Introspection
{
static public class Program
{
static public int bloop = -10;
static public int bloop2 = -20;
public static void Main()
{
var asm = Assembly.GetExecutingAssembly();
var version = int.Parse(asm.ImageRuntimeVersion.Split('.')[0].Sub... |
Can you help me rewrite this code in C++ instead of Tcl, keeping it the same logically? | package require Tcl 8.4 ;
if {[info exists bloop] && [llength [info functions abs]]} {
puts [expr abs($bloop)]
}
| #if !defined(__cplusplus) || __cplusplus < 201103L
#pragma error("The following code requires at least C++11.")
#else
#endif
|
Write the same algorithm in Java as shown in this Tcl implementation. | package require Tcl 8.4 ;
if {[info exists bloop] && [llength [info functions abs]]} {
puts [expr abs($bloop)]
}
| public class VersCheck {
public static void main(String[] args) {
String vers = System.getProperty("java.version");
vers = vers.substring(0,vers.indexOf('.')) + "." +
vers.substring(vers.indexOf('.')+1,vers.lastIndexOf('.'));
if(Double.parseDouble(vers) >= 1.5){
System.out.println("YAY!");
}else{
Sy... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.