Instruction stringlengths 45 106 | input_code stringlengths 1 13.7k | output_code stringlengths 1 13.7k |
|---|---|---|
Convert this MATLAB snippet to C++ and keep its semantics consistent. | a = []; b='';
isempty(a)
isempty(b)
if (a)
1,
else,
0
end;
| #include <iostream>
#include <cstdlib>
if (object == 0) {
std::cout << "object is null";
}
|
Generate an equivalent Java version of this MATLAB code. | a = []; b='';
isempty(a)
isempty(b)
if (a)
1,
else,
0
end;
| module NullObject
{
void run()
{
@Inject Console console;
console.print($"Null value={Null}, Null.toString()={Null.toString()}");
String? s = Null;
String s2 = "test";
console.print($"s={s}, s2={s2}, (s==s2)={s==s2}");
Int len = s?.size : 0;
console.print($"len={len}");
if (String test ?= s)
{
}
else
{
s = "a non-null value";
}
s2 = s;
console.print($"s={s}, s2={s2}, (s==s2)={s==s2}");
}
}
|
Write the same algorithm in Python as shown in this MATLAB implementation. | a = []; b='';
isempty(a)
isempty(b)
if (a)
1,
else,
0
end;
| x = None
if x is None:
print "x is None"
else:
print "x is not None"
|
Please provide an equivalent version of this MATLAB code in VB. | a = []; b='';
isempty(a)
isempty(b)
if (a)
1,
else,
0
end;
| Public Sub Main()
Dim c As VBA.Collection
Debug.Print c Is Nothing
Set c = New VBA.Collection
Debug.Print Not c Is Nothing
Set c = Nothing
Debug.Print c Is Nothing
End Sub
|
Rewrite the snippet below in Go so it works the same as the original MATLAB code. | a = []; b='';
isempty(a)
isempty(b)
if (a)
1,
else,
0
end;
| package main
import "fmt"
var (
s []int
p *int
f func()
i interface{}
m map[int]int
c chan int
)
func main() {
fmt.Println(s == nil)
fmt.Println(p == nil)
fmt.Println(f == nil)
fmt.Println(i == nil)
fmt.Println(m == nil)
fmt.Println(c == nil)
}
|
Write the same algorithm in C as shown in this Nim implementation. | let s: pointer = nil
{.experimental: "notnil".}
let ns: pointer not nil = nil
| #include <stdio.h>
int main()
{
char *object = 0;
if (object == NULL) {
puts("object is null");
}
return 0;
}
|
Change the programming language of this snippet from Nim to C# without modifying what it does. | let s: pointer = nil
{.experimental: "notnil".}
let ns: pointer not nil = nil
| if (foo == null)
Console.WriteLine("foo is null");
|
Rewrite this program in C++ while keeping its functionality equivalent to the Nim version. | let s: pointer = nil
{.experimental: "notnil".}
let ns: pointer not nil = nil
| #include <iostream>
#include <cstdlib>
if (object == 0) {
std::cout << "object is null";
}
|
Write the same code in Java as shown below in Nim. | let s: pointer = nil
{.experimental: "notnil".}
let ns: pointer not nil = nil
| module NullObject
{
void run()
{
@Inject Console console;
console.print($"Null value={Null}, Null.toString()={Null.toString()}");
String? s = Null;
String s2 = "test";
console.print($"s={s}, s2={s2}, (s==s2)={s==s2}");
Int len = s?.size : 0;
console.print($"len={len}");
if (String test ?= s)
{
}
else
{
s = "a non-null value";
}
s2 = s;
console.print($"s={s}, s2={s2}, (s==s2)={s==s2}");
}
}
|
Port the provided Nim code into Python while preserving the original functionality. | let s: pointer = nil
{.experimental: "notnil".}
let ns: pointer not nil = nil
| x = None
if x is None:
print "x is None"
else:
print "x is not None"
|
Generate a VB translation of this Nim snippet without changing its computational steps. | let s: pointer = nil
{.experimental: "notnil".}
let ns: pointer not nil = nil
| Public Sub Main()
Dim c As VBA.Collection
Debug.Print c Is Nothing
Set c = New VBA.Collection
Debug.Print Not c Is Nothing
Set c = Nothing
Debug.Print c Is Nothing
End Sub
|
Produce a language-to-language conversion: from Nim to Go, same semantics. | let s: pointer = nil
{.experimental: "notnil".}
let ns: pointer not nil = nil
| package main
import "fmt"
var (
s []int
p *int
f func()
i interface{}
m map[int]int
c chan int
)
func main() {
fmt.Println(s == nil)
fmt.Println(p == nil)
fmt.Println(f == nil)
fmt.Println(i == nil)
fmt.Println(m == nil)
fmt.Println(c == nil)
}
|
Change the following OCaml code into C without altering its purpose. | type 'a option = None | Some of 'a
| #include <stdio.h>
int main()
{
char *object = 0;
if (object == NULL) {
puts("object is null");
}
return 0;
}
|
Produce a functionally identical C++ code for the snippet given in OCaml. | type 'a option = None | Some of 'a
| #include <iostream>
#include <cstdlib>
if (object == 0) {
std::cout << "object is null";
}
|
Produce a functionally identical Java code for the snippet given in OCaml. | type 'a option = None | Some of 'a
| module NullObject
{
void run()
{
@Inject Console console;
console.print($"Null value={Null}, Null.toString()={Null.toString()}");
String? s = Null;
String s2 = "test";
console.print($"s={s}, s2={s2}, (s==s2)={s==s2}");
Int len = s?.size : 0;
console.print($"len={len}");
if (String test ?= s)
{
}
else
{
s = "a non-null value";
}
s2 = s;
console.print($"s={s}, s2={s2}, (s==s2)={s==s2}");
}
}
|
Produce a language-to-language conversion: from OCaml to Python, same semantics. | type 'a option = None | Some of 'a
| x = None
if x is None:
print "x is None"
else:
print "x is not None"
|
Write a version of this OCaml function in VB with identical behavior. | type 'a option = None | Some of 'a
| Public Sub Main()
Dim c As VBA.Collection
Debug.Print c Is Nothing
Set c = New VBA.Collection
Debug.Print Not c Is Nothing
Set c = Nothing
Debug.Print c Is Nothing
End Sub
|
Maintain the same structure and functionality when rewriting this code in Go. | type 'a option = None | Some of 'a
| package main
import "fmt"
var (
s []int
p *int
f func()
i interface{}
m map[int]int
c chan int
)
func main() {
fmt.Println(s == nil)
fmt.Println(p == nil)
fmt.Println(f == nil)
fmt.Println(i == nil)
fmt.Println(m == nil)
fmt.Println(c == nil)
}
|
Rewrite the snippet below in C so it works the same as the original Perl code. | print defined($x) ? 'Defined' : 'Undefined', ".\n";
| #include <stdio.h>
int main()
{
char *object = 0;
if (object == NULL) {
puts("object is null");
}
return 0;
}
|
Rewrite the snippet below in C++ so it works the same as the original Perl code. | print defined($x) ? 'Defined' : 'Undefined', ".\n";
| #include <iostream>
#include <cstdlib>
if (object == 0) {
std::cout << "object is null";
}
|
Produce a functionally identical Java code for the snippet given in Perl. | print defined($x) ? 'Defined' : 'Undefined', ".\n";
| module NullObject
{
void run()
{
@Inject Console console;
console.print($"Null value={Null}, Null.toString()={Null.toString()}");
String? s = Null;
String s2 = "test";
console.print($"s={s}, s2={s2}, (s==s2)={s==s2}");
Int len = s?.size : 0;
console.print($"len={len}");
if (String test ?= s)
{
}
else
{
s = "a non-null value";
}
s2 = s;
console.print($"s={s}, s2={s2}, (s==s2)={s==s2}");
}
}
|
Keep all operations the same but rewrite the snippet in Python. | print defined($x) ? 'Defined' : 'Undefined', ".\n";
| x = None
if x is None:
print "x is None"
else:
print "x is not None"
|
Preserve the algorithm and functionality while converting the code from Perl to VB. | print defined($x) ? 'Defined' : 'Undefined', ".\n";
| Public Sub Main()
Dim c As VBA.Collection
Debug.Print c Is Nothing
Set c = New VBA.Collection
Debug.Print Not c Is Nothing
Set c = Nothing
Debug.Print c Is Nothing
End Sub
|
Write the same algorithm in Go as shown in this Perl implementation. | print defined($x) ? 'Defined' : 'Undefined', ".\n";
| package main
import "fmt"
var (
s []int
p *int
f func()
i interface{}
m map[int]int
c chan int
)
func main() {
fmt.Println(s == nil)
fmt.Println(p == nil)
fmt.Println(f == nil)
fmt.Println(i == nil)
fmt.Println(m == nil)
fmt.Println(c == nil)
}
|
Maintain the same structure and functionality when rewriting this code in C. | if ($null -eq $object) {
...
}
| #include <stdio.h>
int main()
{
char *object = 0;
if (object == NULL) {
puts("object is null");
}
return 0;
}
|
Generate an equivalent C++ version of this PowerShell code. | if ($null -eq $object) {
...
}
| #include <iostream>
#include <cstdlib>
if (object == 0) {
std::cout << "object is null";
}
|
Keep all operations the same but rewrite the snippet in Java. | if ($null -eq $object) {
...
}
| module NullObject
{
void run()
{
@Inject Console console;
console.print($"Null value={Null}, Null.toString()={Null.toString()}");
String? s = Null;
String s2 = "test";
console.print($"s={s}, s2={s2}, (s==s2)={s==s2}");
Int len = s?.size : 0;
console.print($"len={len}");
if (String test ?= s)
{
}
else
{
s = "a non-null value";
}
s2 = s;
console.print($"s={s}, s2={s2}, (s==s2)={s==s2}");
}
}
|
Convert this PowerShell snippet to Python and keep its semantics consistent. | if ($null -eq $object) {
...
}
| x = None
if x is None:
print "x is None"
else:
print "x is not None"
|
Preserve the algorithm and functionality while converting the code from PowerShell to VB. | if ($null -eq $object) {
...
}
| Public Sub Main()
Dim c As VBA.Collection
Debug.Print c Is Nothing
Set c = New VBA.Collection
Debug.Print Not c Is Nothing
Set c = Nothing
Debug.Print c Is Nothing
End Sub
|
Preserve the algorithm and functionality while converting the code from PowerShell to Go. | if ($null -eq $object) {
...
}
| package main
import "fmt"
var (
s []int
p *int
f func()
i interface{}
m map[int]int
c chan int
)
func main() {
fmt.Println(s == nil)
fmt.Println(p == nil)
fmt.Println(f == nil)
fmt.Println(i == nil)
fmt.Println(m == nil)
fmt.Println(c == nil)
}
|
Port the following code from R to C with equivalent syntax and logic. | is.null(NULL)
is.null(123)
is.null(NA)
123==NULL
foo <- function(){}
foo()
| #include <stdio.h>
int main()
{
char *object = 0;
if (object == NULL) {
puts("object is null");
}
return 0;
}
|
Convert this R snippet to C# and keep its semantics consistent. | is.null(NULL)
is.null(123)
is.null(NA)
123==NULL
foo <- function(){}
foo()
| if (foo == null)
Console.WriteLine("foo is null");
|
Port the following code from R to C++ with equivalent syntax and logic. | is.null(NULL)
is.null(123)
is.null(NA)
123==NULL
foo <- function(){}
foo()
| #include <iostream>
#include <cstdlib>
if (object == 0) {
std::cout << "object is null";
}
|
Produce a language-to-language conversion: from R to Java, same semantics. | is.null(NULL)
is.null(123)
is.null(NA)
123==NULL
foo <- function(){}
foo()
| module NullObject
{
void run()
{
@Inject Console console;
console.print($"Null value={Null}, Null.toString()={Null.toString()}");
String? s = Null;
String s2 = "test";
console.print($"s={s}, s2={s2}, (s==s2)={s==s2}");
Int len = s?.size : 0;
console.print($"len={len}");
if (String test ?= s)
{
}
else
{
s = "a non-null value";
}
s2 = s;
console.print($"s={s}, s2={s2}, (s==s2)={s==s2}");
}
}
|
Keep all operations the same but rewrite the snippet in Python. | is.null(NULL)
is.null(123)
is.null(NA)
123==NULL
foo <- function(){}
foo()
| x = None
if x is None:
print "x is None"
else:
print "x is not None"
|
Keep all operations the same but rewrite the snippet in VB. | is.null(NULL)
is.null(123)
is.null(NA)
123==NULL
foo <- function(){}
foo()
| Public Sub Main()
Dim c As VBA.Collection
Debug.Print c Is Nothing
Set c = New VBA.Collection
Debug.Print Not c Is Nothing
Set c = Nothing
Debug.Print c Is Nothing
End Sub
|
Convert this R block to Go, preserving its control flow and logic. | is.null(NULL)
is.null(123)
is.null(NA)
123==NULL
foo <- function(){}
foo()
| package main
import "fmt"
var (
s []int
p *int
f func()
i interface{}
m map[int]int
c chan int
)
func main() {
fmt.Println(s == nil)
fmt.Println(p == nil)
fmt.Println(f == nil)
fmt.Println(i == nil)
fmt.Println(m == nil)
fmt.Println(c == nil)
}
|
Translate this program into C but keep the logic exactly as in Racket. | -> null
'()
-> (null? null)
#t
-> (null? 3)
#f
| #include <stdio.h>
int main()
{
char *object = 0;
if (object == NULL) {
puts("object is null");
}
return 0;
}
|
Transform the following Racket implementation into C#, maintaining the same output and logic. | -> null
'()
-> (null? null)
#t
-> (null? 3)
#f
| if (foo == null)
Console.WriteLine("foo is null");
|
Port the following code from Racket to C++ with equivalent syntax and logic. | -> null
'()
-> (null? null)
#t
-> (null? 3)
#f
| #include <iostream>
#include <cstdlib>
if (object == 0) {
std::cout << "object is null";
}
|
Translate this program into Java but keep the logic exactly as in Racket. | -> null
'()
-> (null? null)
#t
-> (null? 3)
#f
| module NullObject
{
void run()
{
@Inject Console console;
console.print($"Null value={Null}, Null.toString()={Null.toString()}");
String? s = Null;
String s2 = "test";
console.print($"s={s}, s2={s2}, (s==s2)={s==s2}");
Int len = s?.size : 0;
console.print($"len={len}");
if (String test ?= s)
{
}
else
{
s = "a non-null value";
}
s2 = s;
console.print($"s={s}, s2={s2}, (s==s2)={s==s2}");
}
}
|
Transform the following Racket implementation into Python, maintaining the same output and logic. | -> null
'()
-> (null? null)
#t
-> (null? 3)
#f
| x = None
if x is None:
print "x is None"
else:
print "x is not None"
|
Preserve the algorithm and functionality while converting the code from Racket to VB. | -> null
'()
-> (null? null)
#t
-> (null? 3)
#f
| Public Sub Main()
Dim c As VBA.Collection
Debug.Print c Is Nothing
Set c = New VBA.Collection
Debug.Print Not c Is Nothing
Set c = Nothing
Debug.Print c Is Nothing
End Sub
|
Write a version of this Racket function in Go with identical behavior. | -> null
'()
-> (null? null)
#t
-> (null? 3)
#f
| package main
import "fmt"
var (
s []int
p *int
f func()
i interface{}
m map[int]int
c chan int
)
func main() {
fmt.Println(s == nil)
fmt.Println(p == nil)
fmt.Println(f == nil)
fmt.Println(i == nil)
fmt.Println(m == nil)
fmt.Println(c == nil)
}
|
Rewrite this program in C while keeping its functionality equivalent to the COBOL version. | identification division.
program-id. null-objects.
remarks. test with cobc -x -j null-objects.cob
data division.
working-storage section.
01 thing-not-thing usage pointer.
procedure division.
call "test-null" using thing-not-thing omitted returning nothing
goback.
end program null-objects.
identification division.
program-id. test-null.
data division.
linkage section.
01 thing-one usage pointer.
01 thing-two pic x.
procedure division using
thing-one
optional thing-two
returning omitted.
if thing-one equal null then
display "thing-one pointer to null" upon syserr
end-if
if thing-two omitted then
display "no thing-two was passed" upon syserr
end-if
goback.
end program test-null.
| #include <stdio.h>
int main()
{
char *object = 0;
if (object == NULL) {
puts("object is null");
}
return 0;
}
|
Translate this program into C# but keep the logic exactly as in COBOL. | identification division.
program-id. null-objects.
remarks. test with cobc -x -j null-objects.cob
data division.
working-storage section.
01 thing-not-thing usage pointer.
procedure division.
call "test-null" using thing-not-thing omitted returning nothing
goback.
end program null-objects.
identification division.
program-id. test-null.
data division.
linkage section.
01 thing-one usage pointer.
01 thing-two pic x.
procedure division using
thing-one
optional thing-two
returning omitted.
if thing-one equal null then
display "thing-one pointer to null" upon syserr
end-if
if thing-two omitted then
display "no thing-two was passed" upon syserr
end-if
goback.
end program test-null.
| if (foo == null)
Console.WriteLine("foo is null");
|
Ensure the translated C++ code behaves exactly like the original COBOL snippet. | identification division.
program-id. null-objects.
remarks. test with cobc -x -j null-objects.cob
data division.
working-storage section.
01 thing-not-thing usage pointer.
procedure division.
call "test-null" using thing-not-thing omitted returning nothing
goback.
end program null-objects.
identification division.
program-id. test-null.
data division.
linkage section.
01 thing-one usage pointer.
01 thing-two pic x.
procedure division using
thing-one
optional thing-two
returning omitted.
if thing-one equal null then
display "thing-one pointer to null" upon syserr
end-if
if thing-two omitted then
display "no thing-two was passed" upon syserr
end-if
goback.
end program test-null.
| #include <iostream>
#include <cstdlib>
if (object == 0) {
std::cout << "object is null";
}
|
Write a version of this COBOL function in Java with identical behavior. | identification division.
program-id. null-objects.
remarks. test with cobc -x -j null-objects.cob
data division.
working-storage section.
01 thing-not-thing usage pointer.
procedure division.
call "test-null" using thing-not-thing omitted returning nothing
goback.
end program null-objects.
identification division.
program-id. test-null.
data division.
linkage section.
01 thing-one usage pointer.
01 thing-two pic x.
procedure division using
thing-one
optional thing-two
returning omitted.
if thing-one equal null then
display "thing-one pointer to null" upon syserr
end-if
if thing-two omitted then
display "no thing-two was passed" upon syserr
end-if
goback.
end program test-null.
| module NullObject
{
void run()
{
@Inject Console console;
console.print($"Null value={Null}, Null.toString()={Null.toString()}");
String? s = Null;
String s2 = "test";
console.print($"s={s}, s2={s2}, (s==s2)={s==s2}");
Int len = s?.size : 0;
console.print($"len={len}");
if (String test ?= s)
{
}
else
{
s = "a non-null value";
}
s2 = s;
console.print($"s={s}, s2={s2}, (s==s2)={s==s2}");
}
}
|
Can you help me rewrite this code in Python instead of COBOL, keeping it the same logically? | identification division.
program-id. null-objects.
remarks. test with cobc -x -j null-objects.cob
data division.
working-storage section.
01 thing-not-thing usage pointer.
procedure division.
call "test-null" using thing-not-thing omitted returning nothing
goback.
end program null-objects.
identification division.
program-id. test-null.
data division.
linkage section.
01 thing-one usage pointer.
01 thing-two pic x.
procedure division using
thing-one
optional thing-two
returning omitted.
if thing-one equal null then
display "thing-one pointer to null" upon syserr
end-if
if thing-two omitted then
display "no thing-two was passed" upon syserr
end-if
goback.
end program test-null.
| x = None
if x is None:
print "x is None"
else:
print "x is not None"
|
Produce a functionally identical VB code for the snippet given in COBOL. | identification division.
program-id. null-objects.
remarks. test with cobc -x -j null-objects.cob
data division.
working-storage section.
01 thing-not-thing usage pointer.
procedure division.
call "test-null" using thing-not-thing omitted returning nothing
goback.
end program null-objects.
identification division.
program-id. test-null.
data division.
linkage section.
01 thing-one usage pointer.
01 thing-two pic x.
procedure division using
thing-one
optional thing-two
returning omitted.
if thing-one equal null then
display "thing-one pointer to null" upon syserr
end-if
if thing-two omitted then
display "no thing-two was passed" upon syserr
end-if
goback.
end program test-null.
| Public Sub Main()
Dim c As VBA.Collection
Debug.Print c Is Nothing
Set c = New VBA.Collection
Debug.Print Not c Is Nothing
Set c = Nothing
Debug.Print c Is Nothing
End Sub
|
Write the same code in Go as shown below in COBOL. | identification division.
program-id. null-objects.
remarks. test with cobc -x -j null-objects.cob
data division.
working-storage section.
01 thing-not-thing usage pointer.
procedure division.
call "test-null" using thing-not-thing omitted returning nothing
goback.
end program null-objects.
identification division.
program-id. test-null.
data division.
linkage section.
01 thing-one usage pointer.
01 thing-two pic x.
procedure division using
thing-one
optional thing-two
returning omitted.
if thing-one equal null then
display "thing-one pointer to null" upon syserr
end-if
if thing-two omitted then
display "no thing-two was passed" upon syserr
end-if
goback.
end program test-null.
| package main
import "fmt"
var (
s []int
p *int
f func()
i interface{}
m map[int]int
c chan int
)
func main() {
fmt.Println(s == nil)
fmt.Println(p == nil)
fmt.Println(f == nil)
fmt.Println(i == nil)
fmt.Println(m == nil)
fmt.Println(c == nil)
}
|
Please provide an equivalent version of this REXX code in C. |
options replace format comments java crossref symbols binary
robject = Rexx -- create an object for which the value is undefined
say String.valueOf(robject) -- will report the text "null"
if robject = null then say 'Really, it''s "null"!'
| #include <stdio.h>
int main()
{
char *object = 0;
if (object == NULL) {
puts("object is null");
}
return 0;
}
|
Port the provided REXX code into C# while preserving the original functionality. |
options replace format comments java crossref symbols binary
robject = Rexx -- create an object for which the value is undefined
say String.valueOf(robject) -- will report the text "null"
if robject = null then say 'Really, it''s "null"!'
| if (foo == null)
Console.WriteLine("foo is null");
|
Write the same algorithm in C++ as shown in this REXX implementation. |
options replace format comments java crossref symbols binary
robject = Rexx -- create an object for which the value is undefined
say String.valueOf(robject) -- will report the text "null"
if robject = null then say 'Really, it''s "null"!'
| #include <iostream>
#include <cstdlib>
if (object == 0) {
std::cout << "object is null";
}
|
Convert this REXX block to Java, preserving its control flow and logic. |
options replace format comments java crossref symbols binary
robject = Rexx -- create an object for which the value is undefined
say String.valueOf(robject) -- will report the text "null"
if robject = null then say 'Really, it''s "null"!'
| module NullObject
{
void run()
{
@Inject Console console;
console.print($"Null value={Null}, Null.toString()={Null.toString()}");
String? s = Null;
String s2 = "test";
console.print($"s={s}, s2={s2}, (s==s2)={s==s2}");
Int len = s?.size : 0;
console.print($"len={len}");
if (String test ?= s)
{
}
else
{
s = "a non-null value";
}
s2 = s;
console.print($"s={s}, s2={s2}, (s==s2)={s==s2}");
}
}
|
Write a version of this REXX function in Python with identical behavior. |
options replace format comments java crossref symbols binary
robject = Rexx -- create an object for which the value is undefined
say String.valueOf(robject) -- will report the text "null"
if robject = null then say 'Really, it''s "null"!'
| x = None
if x is None:
print "x is None"
else:
print "x is not None"
|
Preserve the algorithm and functionality while converting the code from REXX to VB. |
options replace format comments java crossref symbols binary
robject = Rexx -- create an object for which the value is undefined
say String.valueOf(robject) -- will report the text "null"
if robject = null then say 'Really, it''s "null"!'
| Public Sub Main()
Dim c As VBA.Collection
Debug.Print c Is Nothing
Set c = New VBA.Collection
Debug.Print Not c Is Nothing
Set c = Nothing
Debug.Print c Is Nothing
End Sub
|
Rewrite this program in Go while keeping its functionality equivalent to the REXX version. |
options replace format comments java crossref symbols binary
robject = Rexx -- create an object for which the value is undefined
say String.valueOf(robject) -- will report the text "null"
if robject = null then say 'Really, it''s "null"!'
| package main
import "fmt"
var (
s []int
p *int
f func()
i interface{}
m map[int]int
c chan int
)
func main() {
fmt.Println(s == nil)
fmt.Println(p == nil)
fmt.Println(f == nil)
fmt.Println(i == nil)
fmt.Println(m == nil)
fmt.Println(c == nil)
}
|
Write the same code in C as shown below in Ruby. | puts "@object is nil" if @object.nil?
puts "$object is nil" if $object.nil?
object = 1 if false
puts "object is nil" if object.nil?
puts nil.class
| #include <stdio.h>
int main()
{
char *object = 0;
if (object == NULL) {
puts("object is null");
}
return 0;
}
|
Transform the following Ruby implementation into C#, maintaining the same output and logic. | puts "@object is nil" if @object.nil?
puts "$object is nil" if $object.nil?
object = 1 if false
puts "object is nil" if object.nil?
puts nil.class
| if (foo == null)
Console.WriteLine("foo is null");
|
Rewrite this program in C++ while keeping its functionality equivalent to the Ruby version. | puts "@object is nil" if @object.nil?
puts "$object is nil" if $object.nil?
object = 1 if false
puts "object is nil" if object.nil?
puts nil.class
| #include <iostream>
#include <cstdlib>
if (object == 0) {
std::cout << "object is null";
}
|
Can you help me rewrite this code in Java instead of Ruby, keeping it the same logically? | puts "@object is nil" if @object.nil?
puts "$object is nil" if $object.nil?
object = 1 if false
puts "object is nil" if object.nil?
puts nil.class
| module NullObject
{
void run()
{
@Inject Console console;
console.print($"Null value={Null}, Null.toString()={Null.toString()}");
String? s = Null;
String s2 = "test";
console.print($"s={s}, s2={s2}, (s==s2)={s==s2}");
Int len = s?.size : 0;
console.print($"len={len}");
if (String test ?= s)
{
}
else
{
s = "a non-null value";
}
s2 = s;
console.print($"s={s}, s2={s2}, (s==s2)={s==s2}");
}
}
|
Generate an equivalent Python version of this Ruby code. | puts "@object is nil" if @object.nil?
puts "$object is nil" if $object.nil?
object = 1 if false
puts "object is nil" if object.nil?
puts nil.class
| x = None
if x is None:
print "x is None"
else:
print "x is not None"
|
Rewrite this program in VB while keeping its functionality equivalent to the Ruby version. | puts "@object is nil" if @object.nil?
puts "$object is nil" if $object.nil?
object = 1 if false
puts "object is nil" if object.nil?
puts nil.class
| Public Sub Main()
Dim c As VBA.Collection
Debug.Print c Is Nothing
Set c = New VBA.Collection
Debug.Print Not c Is Nothing
Set c = Nothing
Debug.Print c Is Nothing
End Sub
|
Change the following Ruby code into Go without altering its purpose. | puts "@object is nil" if @object.nil?
puts "$object is nil" if $object.nil?
object = 1 if false
puts "object is nil" if object.nil?
puts nil.class
| package main
import "fmt"
var (
s []int
p *int
f func()
i interface{}
m map[int]int
c chan int
)
func main() {
fmt.Println(s == nil)
fmt.Println(p == nil)
fmt.Println(f == nil)
fmt.Println(i == nil)
fmt.Println(m == nil)
fmt.Println(c == nil)
}
|
Ensure the translated C code behaves exactly like the original Scala snippet. |
fun main(args: Array<String>) {
val i: Int = 3
println(i)
val j: Int? = null
println(j)
println(null is Nothing?)
}
| #include <stdio.h>
int main()
{
char *object = 0;
if (object == NULL) {
puts("object is null");
}
return 0;
}
|
Keep all operations the same but rewrite the snippet in C#. |
fun main(args: Array<String>) {
val i: Int = 3
println(i)
val j: Int? = null
println(j)
println(null is Nothing?)
}
| if (foo == null)
Console.WriteLine("foo is null");
|
Convert this Scala snippet to C++ and keep its semantics consistent. |
fun main(args: Array<String>) {
val i: Int = 3
println(i)
val j: Int? = null
println(j)
println(null is Nothing?)
}
| #include <iostream>
#include <cstdlib>
if (object == 0) {
std::cout << "object is null";
}
|
Can you help me rewrite this code in Java instead of Scala, keeping it the same logically? |
fun main(args: Array<String>) {
val i: Int = 3
println(i)
val j: Int? = null
println(j)
println(null is Nothing?)
}
| module NullObject
{
void run()
{
@Inject Console console;
console.print($"Null value={Null}, Null.toString()={Null.toString()}");
String? s = Null;
String s2 = "test";
console.print($"s={s}, s2={s2}, (s==s2)={s==s2}");
Int len = s?.size : 0;
console.print($"len={len}");
if (String test ?= s)
{
}
else
{
s = "a non-null value";
}
s2 = s;
console.print($"s={s}, s2={s2}, (s==s2)={s==s2}");
}
}
|
Can you help me rewrite this code in Python instead of Scala, keeping it the same logically? |
fun main(args: Array<String>) {
val i: Int = 3
println(i)
val j: Int? = null
println(j)
println(null is Nothing?)
}
| x = None
if x is None:
print "x is None"
else:
print "x is not None"
|
Transform the following Scala implementation into VB, maintaining the same output and logic. |
fun main(args: Array<String>) {
val i: Int = 3
println(i)
val j: Int? = null
println(j)
println(null is Nothing?)
}
| Public Sub Main()
Dim c As VBA.Collection
Debug.Print c Is Nothing
Set c = New VBA.Collection
Debug.Print Not c Is Nothing
Set c = Nothing
Debug.Print c Is Nothing
End Sub
|
Please provide an equivalent version of this Scala code in Go. |
fun main(args: Array<String>) {
val i: Int = 3
println(i)
val j: Int? = null
println(j)
println(null is Nothing?)
}
| package main
import "fmt"
var (
s []int
p *int
f func()
i interface{}
m map[int]int
c chan int
)
func main() {
fmt.Println(s == nil)
fmt.Println(p == nil)
fmt.Println(f == nil)
fmt.Println(i == nil)
fmt.Println(m == nil)
fmt.Println(c == nil)
}
|
Ensure the translated C code behaves exactly like the original Swift snippet. | let maybeInt: Int? = nil
| #include <stdio.h>
int main()
{
char *object = 0;
if (object == NULL) {
puts("object is null");
}
return 0;
}
|
Produce a language-to-language conversion: from Swift to C++, same semantics. | let maybeInt: Int? = nil
| #include <iostream>
#include <cstdlib>
if (object == 0) {
std::cout << "object is null";
}
|
Write a version of this Swift function in Java with identical behavior. | let maybeInt: Int? = nil
| module NullObject
{
void run()
{
@Inject Console console;
console.print($"Null value={Null}, Null.toString()={Null.toString()}");
String? s = Null;
String s2 = "test";
console.print($"s={s}, s2={s2}, (s==s2)={s==s2}");
Int len = s?.size : 0;
console.print($"len={len}");
if (String test ?= s)
{
}
else
{
s = "a non-null value";
}
s2 = s;
console.print($"s={s}, s2={s2}, (s==s2)={s==s2}");
}
}
|
Keep all operations the same but rewrite the snippet in Python. | let maybeInt: Int? = nil
| x = None
if x is None:
print "x is None"
else:
print "x is not None"
|
Preserve the algorithm and functionality while converting the code from Swift to VB. | let maybeInt: Int? = nil
| Public Sub Main()
Dim c As VBA.Collection
Debug.Print c Is Nothing
Set c = New VBA.Collection
Debug.Print Not c Is Nothing
Set c = Nothing
Debug.Print c Is Nothing
End Sub
|
Write a version of this Swift function in Go with identical behavior. | let maybeInt: Int? = nil
| package main
import "fmt"
var (
s []int
p *int
f func()
i interface{}
m map[int]int
c chan int
)
func main() {
fmt.Println(s == nil)
fmt.Println(p == nil)
fmt.Println(f == nil)
fmt.Println(i == nil)
fmt.Println(m == nil)
fmt.Println(c == nil)
}
|
Transform the following Tcl implementation into C, maintaining the same output and logic. | if {$value eq ""} ...
| #include <stdio.h>
int main()
{
char *object = 0;
if (object == NULL) {
puts("object is null");
}
return 0;
}
|
Rewrite this program in C++ while keeping its functionality equivalent to the Tcl version. | if {$value eq ""} ...
| #include <iostream>
#include <cstdlib>
if (object == 0) {
std::cout << "object is null";
}
|
Write a version of this Tcl function in Java with identical behavior. | if {$value eq ""} ...
| module NullObject
{
void run()
{
@Inject Console console;
console.print($"Null value={Null}, Null.toString()={Null.toString()}");
String? s = Null;
String s2 = "test";
console.print($"s={s}, s2={s2}, (s==s2)={s==s2}");
Int len = s?.size : 0;
console.print($"len={len}");
if (String test ?= s)
{
}
else
{
s = "a non-null value";
}
s2 = s;
console.print($"s={s}, s2={s2}, (s==s2)={s==s2}");
}
}
|
Convert this Tcl snippet to VB and keep its semantics consistent. | if {$value eq ""} ...
| Public Sub Main()
Dim c As VBA.Collection
Debug.Print c Is Nothing
Set c = New VBA.Collection
Debug.Print Not c Is Nothing
Set c = Nothing
Debug.Print c Is Nothing
End Sub
|
Ensure the translated Go code behaves exactly like the original Tcl snippet. | if {$value eq ""} ...
| package main
import "fmt"
var (
s []int
p *int
f func()
i interface{}
m map[int]int
c chan int
)
func main() {
fmt.Println(s == nil)
fmt.Println(p == nil)
fmt.Println(f == nil)
fmt.Println(i == nil)
fmt.Println(m == nil)
fmt.Println(c == nil)
}
|
Produce a language-to-language conversion: from Rust to PHP, same semantics. |
fn check_number(num: &Option<u8>) {
if num.is_none() {
println!("Number is: None");
} else {
println!("Number is: {}", num.unwrap());
}
}
fn main() {
let mut possible_number: Option<u8> = None;
check_number(&possible_number);
possible_number = Some(31);
check_number(&possible_number);
}
| $x = NULL;
if (is_null($x))
echo "\$x is null\n";
|
Preserve the algorithm and functionality while converting the code from Ada to PHP. | with Ada.Text_Io;
if Object = null then
Ada.Text_Io.Put_line("object is null");
end if;
| $x = NULL;
if (is_null($x))
echo "\$x is null\n";
|
Produce a language-to-language conversion: from Arturo to PHP, same semantics. | v: null
if v=null -> print "got NULL!"
| $x = NULL;
if (is_null($x))
echo "\$x is null\n";
|
Convert the following code from AutoHotKey to PHP, ensuring the logic remains intact. | If (object == null)
MsgBox, object is null
| $x = NULL;
if (is_null($x))
echo "\$x is null\n";
|
Translate the given AWK code snippet into PHP without altering its behavior. |
BEGIN {
b=0;
print "<"b,length(b)">"
print "<"u,length(u)">"
print "<"u+0,length(u+0)">";
}
| $x = NULL;
if (is_null($x))
echo "\$x is null\n";
|
Change the programming language of this snippet from BBC_Basic to PHP without modifying what it does. | PROCtestobjects
END
DEF PROCtestobjects
PRIVATE a(), b(), s{}, t{}
DIM a(123)
DIM s{a%, b#, c$}
IF !^a() <= 1 PRINT "a() is null" ELSE PRINT "a() is not null"
IF !^b() <= 1 PRINT "b() is null" ELSE PRINT "b() is not null"
IF !^s{} <= 1 PRINT "s{} is null" ELSE PRINT "s{} is not null"
IF !^t{} <= 1 PRINT "t{} is null" ELSE PRINT "t{} is not null"
ENDPROC
| $x = NULL;
if (is_null($x))
echo "\$x is null\n";
|
Can you help me rewrite this code in PHP instead of Common_Lisp, keeping it the same logically? | (let [x nil]
(println "Object is" (if (nil? x) "nil" "not nil")))
| $x = NULL;
if (is_null($x))
echo "\$x is null\n";
|
Ensure the translated PHP code behaves exactly like the original D snippet. | import std.stdio;
class K {}
void main() {
K k;
if (k is null)
writeln("k is null");
k = new K;
if (k !is null)
writeln("Now k is not null");
}
| $x = NULL;
if (is_null($x))
echo "\$x is null\n";
|
Preserve the algorithm and functionality while converting the code from Delphi to PHP. |
if lObject = nil then
...
if not Assigned(lObject) then
...
| $x = NULL;
if (is_null($x))
echo "\$x is null\n";
|
Maintain the same structure and functionality when rewriting this code in PHP. | iex(1)> nil == :nil
true
iex(2)> is_nil(nil)
true
| $x = NULL;
if (is_null($x))
echo "\$x is null\n";
|
Transform the following F# implementation into PHP, maintaining the same output and logic. | let sl : string list = [null; "abc"]
let f s =
match s with
| null -> "It is null!"
| _ -> "It's non-null: " + s
for s in sl do printfn "%s" (f s)
| $x = NULL;
if (is_null($x))
echo "\$x is null\n";
|
Generate a PHP translation of this Factor snippet without changing its computational steps. | : is-f? ( obj -- ? ) f = ;
| $x = NULL;
if (is_null($x))
echo "\$x is null\n";
|
Generate a PHP translation of this Haskell snippet without changing its computational steps. | undefined
error "oops"
head []
| $x = NULL;
if (is_null($x))
echo "\$x is null\n";
|
Generate a PHP translation of this Icon snippet without changing its computational steps. | procedure main()
nulltest("a",a)
nulltest("b",b := &null)
nulltest("c",c := "anything")
nulltest("c",c := &null)
end
procedure nulltest(name,var)
return write(name, if /var then " is" else " is not"," null.")
end
| $x = NULL;
if (is_null($x))
echo "\$x is null\n";
|
Write the same code in PHP as shown below in Lua. | isnil = (object == nil)
print(isnil)
| $x = NULL;
if (is_null($x))
echo "\$x is null\n";
|
Rewrite this program in PHP while keeping its functionality equivalent to the MATLAB version. | a = []; b='';
isempty(a)
isempty(b)
if (a)
1,
else,
0
end;
| $x = NULL;
if (is_null($x))
echo "\$x is null\n";
|
Generate an equivalent PHP version of this Nim code. | let s: pointer = nil
{.experimental: "notnil".}
let ns: pointer not nil = nil
| $x = NULL;
if (is_null($x))
echo "\$x is null\n";
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.