Instruction stringlengths 45 106 | input_code stringlengths 1 13.7k | output_code stringlengths 1 13.7k |
|---|---|---|
Port the provided Racket code into Go while preserving the original functionality. | #lang racket
(define/contract x
(=/c 42)
42)
(define/contract f
(-> number? (or/c 'yes 'no))
(lambda (x)
(if (= 42 x) 'yes 'no)))
(f 42)
(f "foo")
| package main
func main() {
x := 43
if x != 42 {
panic(42)
}
}
|
Write the same code in C as shown below in REXX. |
* There's no assert feature in Rexx. That's how I'd implement it
* 10.08.2012 Walter Pachl
**********************************************************************/
x.=42
x.2=11
Do i=1 By 1
Call assert x.i,42
End
Exit
assert:
Parse Arg assert_have,assert_should_have
If assert_have\==assert_should_have Then Do
Say 'Assertion fails in line' sigl
Say 'expected:' assert_should_have
Say ' found:' assert_have
Say sourceline(sigl)
Say 'Look around'
Trace ?R
Nop
Signal Syntax
End
Return
Syntax: Say 'program terminated'
| #include <assert.h>
int main(){
int a;
assert(a == 42);
return 0;
}
|
Rewrite the snippet below in C# so it works the same as the original REXX code. |
* There's no assert feature in Rexx. That's how I'd implement it
* 10.08.2012 Walter Pachl
**********************************************************************/
x.=42
x.2=11
Do i=1 By 1
Call assert x.i,42
End
Exit
assert:
Parse Arg assert_have,assert_should_have
If assert_have\==assert_should_have Then Do
Say 'Assertion fails in line' sigl
Say 'expected:' assert_should_have
Say ' found:' assert_have
Say sourceline(sigl)
Say 'Look around'
Trace ?R
Nop
Signal Syntax
End
Return
Syntax: Say 'program terminated'
| using System.Diagnostics;
static class Program
{
static void Main()
{
int a = 0;
Console.WriteLine("Before");
Trace.Assert(a == 42, "Trace assertion failed");
Console.WriteLine("After Trace.Assert");
Debug.Assert(a == 42, "Debug assertion failed");
Console.WriteLine("After Debug.Assert");
}
}
|
Ensure the translated C++ code behaves exactly like the original REXX snippet. |
* There's no assert feature in Rexx. That's how I'd implement it
* 10.08.2012 Walter Pachl
**********************************************************************/
x.=42
x.2=11
Do i=1 By 1
Call assert x.i,42
End
Exit
assert:
Parse Arg assert_have,assert_should_have
If assert_have\==assert_should_have Then Do
Say 'Assertion fails in line' sigl
Say 'expected:' assert_should_have
Say ' found:' assert_have
Say sourceline(sigl)
Say 'Look around'
Trace ?R
Nop
Signal Syntax
End
Return
Syntax: Say 'program terminated'
| #include <cassert>
int main()
{
int a;
assert(a == 42);
}
|
Keep all operations the same but rewrite the snippet in Java. |
* There's no assert feature in Rexx. That's how I'd implement it
* 10.08.2012 Walter Pachl
**********************************************************************/
x.=42
x.2=11
Do i=1 By 1
Call assert x.i,42
End
Exit
assert:
Parse Arg assert_have,assert_should_have
If assert_have\==assert_should_have Then Do
Say 'Assertion fails in line' sigl
Say 'expected:' assert_should_have
Say ' found:' assert_have
Say sourceline(sigl)
Say 'Look around'
Trace ?R
Nop
Signal Syntax
End
Return
Syntax: Say 'program terminated'
| public class Assertions {
public static void main(String[] args) {
int a = 13;
assert a == 42;
assert a == 42 : "Error message";
}
}
|
Maintain the same structure and functionality when rewriting this code in Python. |
* There's no assert feature in Rexx. That's how I'd implement it
* 10.08.2012 Walter Pachl
**********************************************************************/
x.=42
x.2=11
Do i=1 By 1
Call assert x.i,42
End
Exit
assert:
Parse Arg assert_have,assert_should_have
If assert_have\==assert_should_have Then Do
Say 'Assertion fails in line' sigl
Say 'expected:' assert_should_have
Say ' found:' assert_have
Say sourceline(sigl)
Say 'Look around'
Trace ?R
Nop
Signal Syntax
End
Return
Syntax: Say 'program terminated'
| a = 5
assert a == 42
assert a == 42, "Error message"
|
Generate a VB translation of this REXX snippet without changing its computational steps. |
* There's no assert feature in Rexx. That's how I'd implement it
* 10.08.2012 Walter Pachl
**********************************************************************/
x.=42
x.2=11
Do i=1 By 1
Call assert x.i,42
End
Exit
assert:
Parse Arg assert_have,assert_should_have
If assert_have\==assert_should_have Then Do
Say 'Assertion fails in line' sigl
Say 'expected:' assert_should_have
Say ' found:' assert_have
Say sourceline(sigl)
Say 'Look around'
Trace ?R
Nop
Signal Syntax
End
Return
Syntax: Say 'program terminated'
| Imports System.Diagnostics
Module Program
Sub Main()
Dim a As Integer = 0
Console.WriteLine("Before")
Trace.Assert(a = 42, "Trace assertion failed: The Answer was incorrect")
Console.WriteLine("After Trace.Assert")
Debug.Assert(a = 42, "Debug assertion failed: The Answer was incorrect")
Console.WriteLine("After Debug.Assert")
End Sub
End Module
|
Please provide an equivalent version of this REXX code in Go. |
* There's no assert feature in Rexx. That's how I'd implement it
* 10.08.2012 Walter Pachl
**********************************************************************/
x.=42
x.2=11
Do i=1 By 1
Call assert x.i,42
End
Exit
assert:
Parse Arg assert_have,assert_should_have
If assert_have\==assert_should_have Then Do
Say 'Assertion fails in line' sigl
Say 'expected:' assert_should_have
Say ' found:' assert_have
Say sourceline(sigl)
Say 'Look around'
Trace ?R
Nop
Signal Syntax
End
Return
Syntax: Say 'program terminated'
| package main
func main() {
x := 43
if x != 42 {
panic(42)
}
}
|
Change the following Ruby code into C without altering its purpose. | class AssertionError < Exception
end
def assert(predicate : Bool, msg = "The asserted condition was false")
raise AssertionError.new(msg) unless predicate
end
assert(12 == 42, "It appears that 12 doesn't equal 42")
| #include <assert.h>
int main(){
int a;
assert(a == 42);
return 0;
}
|
Transform the following Ruby implementation into C#, maintaining the same output and logic. | class AssertionError < Exception
end
def assert(predicate : Bool, msg = "The asserted condition was false")
raise AssertionError.new(msg) unless predicate
end
assert(12 == 42, "It appears that 12 doesn't equal 42")
| using System.Diagnostics;
static class Program
{
static void Main()
{
int a = 0;
Console.WriteLine("Before");
Trace.Assert(a == 42, "Trace assertion failed");
Console.WriteLine("After Trace.Assert");
Debug.Assert(a == 42, "Debug assertion failed");
Console.WriteLine("After Debug.Assert");
}
}
|
Translate this program into C++ but keep the logic exactly as in Ruby. | class AssertionError < Exception
end
def assert(predicate : Bool, msg = "The asserted condition was false")
raise AssertionError.new(msg) unless predicate
end
assert(12 == 42, "It appears that 12 doesn't equal 42")
| #include <cassert>
int main()
{
int a;
assert(a == 42);
}
|
Please provide an equivalent version of this Ruby code in Python. | class AssertionError < Exception
end
def assert(predicate : Bool, msg = "The asserted condition was false")
raise AssertionError.new(msg) unless predicate
end
assert(12 == 42, "It appears that 12 doesn't equal 42")
| a = 5
assert a == 42
assert a == 42, "Error message"
|
Port the following code from Ruby to VB with equivalent syntax and logic. | class AssertionError < Exception
end
def assert(predicate : Bool, msg = "The asserted condition was false")
raise AssertionError.new(msg) unless predicate
end
assert(12 == 42, "It appears that 12 doesn't equal 42")
| Imports System.Diagnostics
Module Program
Sub Main()
Dim a As Integer = 0
Console.WriteLine("Before")
Trace.Assert(a = 42, "Trace assertion failed: The Answer was incorrect")
Console.WriteLine("After Trace.Assert")
Debug.Assert(a = 42, "Debug assertion failed: The Answer was incorrect")
Console.WriteLine("After Debug.Assert")
End Sub
End Module
|
Ensure the translated Go code behaves exactly like the original Ruby snippet. | class AssertionError < Exception
end
def assert(predicate : Bool, msg = "The asserted condition was false")
raise AssertionError.new(msg) unless predicate
end
assert(12 == 42, "It appears that 12 doesn't equal 42")
| package main
func main() {
x := 43
if x != 42 {
panic(42)
}
}
|
Change the following Scala code into C without altering its purpose. | assert(a == 42)
assert(a == 42, "a isn't equal to 42")
assume(a == 42)
assume(a == 42, "a isn't equal to 42")
| #include <assert.h>
int main(){
int a;
assert(a == 42);
return 0;
}
|
Change the programming language of this snippet from Scala to C# without modifying what it does. | assert(a == 42)
assert(a == 42, "a isn't equal to 42")
assume(a == 42)
assume(a == 42, "a isn't equal to 42")
| using System.Diagnostics;
static class Program
{
static void Main()
{
int a = 0;
Console.WriteLine("Before");
Trace.Assert(a == 42, "Trace assertion failed");
Console.WriteLine("After Trace.Assert");
Debug.Assert(a == 42, "Debug assertion failed");
Console.WriteLine("After Debug.Assert");
}
}
|
Please provide an equivalent version of this Scala code in C++. | assert(a == 42)
assert(a == 42, "a isn't equal to 42")
assume(a == 42)
assume(a == 42, "a isn't equal to 42")
| #include <cassert>
int main()
{
int a;
assert(a == 42);
}
|
Preserve the algorithm and functionality while converting the code from Scala to Java. | assert(a == 42)
assert(a == 42, "a isn't equal to 42")
assume(a == 42)
assume(a == 42, "a isn't equal to 42")
| public class Assertions {
public static void main(String[] args) {
int a = 13;
assert a == 42;
assert a == 42 : "Error message";
}
}
|
Convert this Scala snippet to Python and keep its semantics consistent. | assert(a == 42)
assert(a == 42, "a isn't equal to 42")
assume(a == 42)
assume(a == 42, "a isn't equal to 42")
| a = 5
assert a == 42
assert a == 42, "Error message"
|
Can you help me rewrite this code in VB instead of Scala, keeping it the same logically? | assert(a == 42)
assert(a == 42, "a isn't equal to 42")
assume(a == 42)
assume(a == 42, "a isn't equal to 42")
| Imports System.Diagnostics
Module Program
Sub Main()
Dim a As Integer = 0
Console.WriteLine("Before")
Trace.Assert(a = 42, "Trace assertion failed: The Answer was incorrect")
Console.WriteLine("After Trace.Assert")
Debug.Assert(a = 42, "Debug assertion failed: The Answer was incorrect")
Console.WriteLine("After Debug.Assert")
End Sub
End Module
|
Can you help me rewrite this code in Go instead of Scala, keeping it the same logically? | assert(a == 42)
assert(a == 42, "a isn't equal to 42")
assume(a == 42)
assume(a == 42, "a isn't equal to 42")
| package main
func main() {
x := 43
if x != 42 {
panic(42)
}
}
|
Produce a language-to-language conversion: from Swift to C, same semantics. | var a = 5
assert(a == 42)
assert(a == 42, "Error message")
| #include <assert.h>
int main(){
int a;
assert(a == 42);
return 0;
}
|
Port the provided Swift code into C# while preserving the original functionality. | var a = 5
assert(a == 42)
assert(a == 42, "Error message")
| using System.Diagnostics;
static class Program
{
static void Main()
{
int a = 0;
Console.WriteLine("Before");
Trace.Assert(a == 42, "Trace assertion failed");
Console.WriteLine("After Trace.Assert");
Debug.Assert(a == 42, "Debug assertion failed");
Console.WriteLine("After Debug.Assert");
}
}
|
Change the following Swift code into C++ without altering its purpose. | var a = 5
assert(a == 42)
assert(a == 42, "Error message")
| #include <cassert>
int main()
{
int a;
assert(a == 42);
}
|
Port the provided Swift code into Java while preserving the original functionality. | var a = 5
assert(a == 42)
assert(a == 42, "Error message")
| public class Assertions {
public static void main(String[] args) {
int a = 13;
assert a == 42;
assert a == 42 : "Error message";
}
}
|
Translate the given Swift code snippet into Python without altering its behavior. | var a = 5
assert(a == 42)
assert(a == 42, "Error message")
| a = 5
assert a == 42
assert a == 42, "Error message"
|
Translate the given Swift code snippet into VB without altering its behavior. | var a = 5
assert(a == 42)
assert(a == 42, "Error message")
| Imports System.Diagnostics
Module Program
Sub Main()
Dim a As Integer = 0
Console.WriteLine("Before")
Trace.Assert(a = 42, "Trace assertion failed: The Answer was incorrect")
Console.WriteLine("After Trace.Assert")
Debug.Assert(a = 42, "Debug assertion failed: The Answer was incorrect")
Console.WriteLine("After Debug.Assert")
End Sub
End Module
|
Preserve the algorithm and functionality while converting the code from Swift to Go. | var a = 5
assert(a == 42)
assert(a == 42, "Error message")
| package main
func main() {
x := 43
if x != 42 {
panic(42)
}
}
|
Convert this Tcl block to C, preserving its control flow and logic. | package require control
set x 5
control::assert {$x == 42}
| #include <assert.h>
int main(){
int a;
assert(a == 42);
return 0;
}
|
Convert this Tcl snippet to C# and keep its semantics consistent. | package require control
set x 5
control::assert {$x == 42}
| using System.Diagnostics;
static class Program
{
static void Main()
{
int a = 0;
Console.WriteLine("Before");
Trace.Assert(a == 42, "Trace assertion failed");
Console.WriteLine("After Trace.Assert");
Debug.Assert(a == 42, "Debug assertion failed");
Console.WriteLine("After Debug.Assert");
}
}
|
Rewrite this program in C++ while keeping its functionality equivalent to the Tcl version. | package require control
set x 5
control::assert {$x == 42}
| #include <cassert>
int main()
{
int a;
assert(a == 42);
}
|
Preserve the algorithm and functionality while converting the code from Tcl to Java. | package require control
set x 5
control::assert {$x == 42}
| public class Assertions {
public static void main(String[] args) {
int a = 13;
assert a == 42;
assert a == 42 : "Error message";
}
}
|
Translate the given Tcl code snippet into Python without altering its behavior. | package require control
set x 5
control::assert {$x == 42}
| a = 5
assert a == 42
assert a == 42, "Error message"
|
Ensure the translated VB code behaves exactly like the original Tcl snippet. | package require control
set x 5
control::assert {$x == 42}
| Imports System.Diagnostics
Module Program
Sub Main()
Dim a As Integer = 0
Console.WriteLine("Before")
Trace.Assert(a = 42, "Trace assertion failed: The Answer was incorrect")
Console.WriteLine("After Trace.Assert")
Debug.Assert(a = 42, "Debug assertion failed: The Answer was incorrect")
Console.WriteLine("After Debug.Assert")
End Sub
End Module
|
Translate this program into Go but keep the logic exactly as in Tcl. | package require control
set x 5
control::assert {$x == 42}
| package main
func main() {
x := 43
if x != 42 {
panic(42)
}
}
|
Ensure the translated PHP code behaves exactly like the original Rust snippet. | let x = 42;
assert!(x == 42);
assert_eq!(x, 42);
| <?php
$a = 5
#...input or change $a here
assert($a == 42) # when $a is not 42, take appropriate actions,
# which is set by assert_options()
?>
|
Rewrite this program in PHP while keeping its functionality equivalent to the Ada version. | pragma Assert (A = 42, "Oops!");
| <?php
$a = 5
#...input or change $a here
assert($a == 42) # when $a is not 42, take appropriate actions,
# which is set by assert_options()
?>
|
Convert this Arturo snippet to PHP and keep its semantics consistent. | a: 42
ensure [a = 42]
| <?php
$a = 5
#...input or change $a here
assert($a == 42) # when $a is not 42, take appropriate actions,
# which is set by assert_options()
?>
|
Generate an equivalent PHP version of this AutoHotKey code. | if (a != 42)
{
OutputDebug, "a != 42"
ListVars
Pause
}
| <?php
$a = 5
#...input or change $a here
assert($a == 42) # when $a is not 42, take appropriate actions,
# which is set by assert_options()
?>
|
Rewrite this program in PHP while keeping its functionality equivalent to the AWK version. | BEGIN {
meaning = 6 * 7
assert(meaning == 42, "Integer mathematics failed")
assert(meaning == 42)
meaning = strtonum("42 also known as forty-two")
assert(meaning == 42, "Built-in function failed")
meaning = "42"
assert(meaning == 42, "Dynamic type conversion failed")
meaning = 6 * 9
assert(meaning == 42, "Ford Prefect's experiment failed")
print "That's all folks"
exit
}
function assert(cond, errormsg){
if (!cond) {
if (errormsg != "") print errormsg
exit 1
}
}
| <?php
$a = 5
#...input or change $a here
assert($a == 42) # when $a is not 42, take appropriate actions,
# which is set by assert_options()
?>
|
Generate a PHP translation of this BBC_Basic snippet without changing its computational steps. | PROCassert(a% = 42)
END
DEF PROCassert(bool%)
IF NOT bool% THEN ERROR 100, "Assertion failed"
ENDPROC
| <?php
$a = 5
#...input or change $a here
assert($a == 42) # when $a is not 42, take appropriate actions,
# which is set by assert_options()
?>
|
Translate this program into PHP but keep the logic exactly as in Clojure. | (let [i 42]
(assert (= i 42)))
| <?php
$a = 5
#...input or change $a here
assert($a == 42) # when $a is not 42, take appropriate actions,
# which is set by assert_options()
?>
|
Please provide an equivalent version of this Common_Lisp code in PHP. | (let ((x 42))
(assert (and (integerp x) (= 42 x)) (x)))
| <?php
$a = 5
#...input or change $a here
assert($a == 42) # when $a is not 42, take appropriate actions,
# which is set by assert_options()
?>
|
Convert the following code from D to PHP, ensuring the logic remains intact. | import std.exception: enforce;
int foo(in bool condition) pure nothrow
in {
assert(condition);
} out(result) {
assert(result > 0);
} body {
if (condition)
return 42;
assert(false, "This can't happen.");
}
void main() pure {
int x = foo(true);
assert(x == 42, "x is not 42");
enforce(x == 42, "x is not 42");
}
| <?php
$a = 5
#...input or change $a here
assert($a == 42) # when $a is not 42, take appropriate actions,
# which is set by assert_options()
?>
|
Keep all operations the same but rewrite the snippet in PHP. | Assert(a = 42);
| <?php
$a = 5
#...input or change $a here
assert($a == 42) # when $a is not 42, take appropriate actions,
# which is set by assert_options()
?>
|
Generate an equivalent PHP version of this Elixir code. | ExUnit.start
defmodule AssertionTest do
use ExUnit.Case
def return_5, do: 5
test "not equal" do
assert 42 == return_5
end
end
| <?php
$a = 5
#...input or change $a here
assert($a == 42) # when $a is not 42, take appropriate actions,
# which is set by assert_options()
?>
|
Port the following code from Erlang to PHP with equivalent syntax and logic. | 1> N = 42.
42
2> N = 43.
** exception error: no match of right hand side value 43
3> N = 42.
42
4> 44 = N.
** exception error: no match of right hand side value 42
5> 42 = N.
42
| <?php
$a = 5
#...input or change $a here
assert($a == 42) # when $a is not 42, take appropriate actions,
# which is set by assert_options()
?>
|
Produce a functionally identical PHP code for the snippet given in F#. | let test x =
assert (x = 42)
test 43
| <?php
$a = 5
#...input or change $a here
assert($a == 42) # when $a is not 42, take appropriate actions,
# which is set by assert_options()
?>
|
Change the programming language of this snippet from Factor to PHP without modifying what it does. | USING: kernel ;
42 assert=
| <?php
$a = 5
#...input or change $a here
assert($a == 42) # when $a is not 42, take appropriate actions,
# which is set by assert_options()
?>
|
Write the same algorithm in PHP as shown in this Groovy implementation. | def checkTheAnswer = {
assert it == 42 : "This: " + it + " is not the answer!"
}
| <?php
$a = 5
#...input or change $a here
assert($a == 42) # when $a is not 42, take appropriate actions,
# which is set by assert_options()
?>
|
Produce a functionally identical PHP code for the snippet given in Haskell. | import Control.Exception
main = let a = someValue in
assert (a == 42)
somethingElse
| <?php
$a = 5
#...input or change $a here
assert($a == 42) # when $a is not 42, take appropriate actions,
# which is set by assert_options()
?>
|
Can you help me rewrite this code in PHP instead of Icon, keeping it the same logically? | ...
runerr(n,( expression ,"Assertion/error - message."))
...
stop(( expression ,"Assertion/stop - message."))
...
| <?php
$a = 5
#...input or change $a here
assert($a == 42) # when $a is not 42, take appropriate actions,
# which is set by assert_options()
?>
|
Transform the following J implementation into PHP, maintaining the same output and logic. | assert n = 42
| <?php
$a = 5
#...input or change $a here
assert($a == 42) # when $a is not 42, take appropriate actions,
# which is set by assert_options()
?>
|
Change the programming language of this snippet from Julia to PHP without modifying what it does. | const x = 5
@assert x == 42
x::String
| <?php
$a = 5
#...input or change $a here
assert($a == 42) # when $a is not 42, take appropriate actions,
# which is set by assert_options()
?>
|
Translate this program into PHP but keep the logic exactly as in Lua. | a = 5
assert (a == 42)
assert (a == 42,'\''..a..'\' is not the answer to life, the universe, and everything')
| <?php
$a = 5
#...input or change $a here
assert($a == 42) # when $a is not 42, take appropriate actions,
# which is set by assert_options()
?>
|
Convert this Mathematica block to PHP, preserving its control flow and logic. | Assert[var===42]
| <?php
$a = 5
#...input or change $a here
assert($a == 42) # when $a is not 42, take appropriate actions,
# which is set by assert_options()
?>
|
Change the following MATLAB code into PHP without altering its purpose. | assert(x == 42,'x =
| <?php
$a = 5
#...input or change $a here
assert($a == 42) # when $a is not 42, take appropriate actions,
# which is set by assert_options()
?>
|
Translate this program into PHP but keep the logic exactly as in Nim. | var a = 42
assert(a == 42, "Not 42!")
| <?php
$a = 5
#...input or change $a here
assert($a == 42) # when $a is not 42, take appropriate actions,
# which is set by assert_options()
?>
|
Maintain the same structure and functionality when rewriting this code in PHP. | let a = get_some_value () in
assert (a = 42);
| <?php
$a = 5
#...input or change $a here
assert($a == 42) # when $a is not 42, take appropriate actions,
# which is set by assert_options()
?>
|
Rewrite the snippet below in PHP so it works the same as the original Perl code. | print "Give me a number: ";
chomp(my $a = <>);
$a == 42 or die "Error message\n";
die "Error message\n" unless $a == 42;
die "Error message\n" if not $a == 42;
die "Error message\n" if $a != 42;
| <?php
$a = 5
#...input or change $a here
assert($a == 42) # when $a is not 42, take appropriate actions,
# which is set by assert_options()
?>
|
Ensure the translated PHP code behaves exactly like the original R snippet. | stopifnot(a==42)
| <?php
$a = 5
#...input or change $a here
assert($a == 42) # when $a is not 42, take appropriate actions,
# which is set by assert_options()
?>
|
Rewrite the snippet below in PHP so it works the same as the original Racket code. | #lang racket
(define/contract x
(=/c 42)
42)
(define/contract f
(-> number? (or/c 'yes 'no))
(lambda (x)
(if (= 42 x) 'yes 'no)))
(f 42)
(f "foo")
| <?php
$a = 5
#...input or change $a here
assert($a == 42) # when $a is not 42, take appropriate actions,
# which is set by assert_options()
?>
|
Convert this REXX block to PHP, preserving its control flow and logic. |
* There's no assert feature in Rexx. That's how I'd implement it
* 10.08.2012 Walter Pachl
**********************************************************************/
x.=42
x.2=11
Do i=1 By 1
Call assert x.i,42
End
Exit
assert:
Parse Arg assert_have,assert_should_have
If assert_have\==assert_should_have Then Do
Say 'Assertion fails in line' sigl
Say 'expected:' assert_should_have
Say ' found:' assert_have
Say sourceline(sigl)
Say 'Look around'
Trace ?R
Nop
Signal Syntax
End
Return
Syntax: Say 'program terminated'
| <?php
$a = 5
#...input or change $a here
assert($a == 42) # when $a is not 42, take appropriate actions,
# which is set by assert_options()
?>
|
Change the programming language of this snippet from Ruby to PHP without modifying what it does. | class AssertionError < Exception
end
def assert(predicate : Bool, msg = "The asserted condition was false")
raise AssertionError.new(msg) unless predicate
end
assert(12 == 42, "It appears that 12 doesn't equal 42")
| <?php
$a = 5
#...input or change $a here
assert($a == 42) # when $a is not 42, take appropriate actions,
# which is set by assert_options()
?>
|
Change the following Scala code into PHP without altering its purpose. | assert(a == 42)
assert(a == 42, "a isn't equal to 42")
assume(a == 42)
assume(a == 42, "a isn't equal to 42")
| <?php
$a = 5
#...input or change $a here
assert($a == 42) # when $a is not 42, take appropriate actions,
# which is set by assert_options()
?>
|
Translate the given Swift code snippet into PHP without altering its behavior. | var a = 5
assert(a == 42)
assert(a == 42, "Error message")
| <?php
$a = 5
#...input or change $a here
assert($a == 42) # when $a is not 42, take appropriate actions,
# which is set by assert_options()
?>
|
Convert this Tcl block to PHP, preserving its control flow and logic. | package require control
set x 5
control::assert {$x == 42}
| <?php
$a = 5
#...input or change $a here
assert($a == 42) # when $a is not 42, take appropriate actions,
# which is set by assert_options()
?>
|
Rewrite this program in Rust while keeping its functionality equivalent to the C version. | #include <assert.h>
int main(){
int a;
assert(a == 42);
return 0;
}
| let x = 42;
assert!(x == 42);
assert_eq!(x, 42);
|
Rewrite the snippet below in Rust so it works the same as the original C++ code. | #include <cassert>
int main()
{
int a;
assert(a == 42);
}
| let x = 42;
assert!(x == 42);
assert_eq!(x, 42);
|
Port the provided C# code into Rust while preserving the original functionality. | using System.Diagnostics;
static class Program
{
static void Main()
{
int a = 0;
Console.WriteLine("Before");
Trace.Assert(a == 42, "Trace assertion failed");
Console.WriteLine("After Trace.Assert");
Debug.Assert(a == 42, "Debug assertion failed");
Console.WriteLine("After Debug.Assert");
}
}
| let x = 42;
assert!(x == 42);
assert_eq!(x, 42);
|
Please provide an equivalent version of this Go code in Rust. | package main
func main() {
x := 43
if x != 42 {
panic(42)
}
}
| let x = 42;
assert!(x == 42);
assert_eq!(x, 42);
|
Rewrite the snippet below in VB so it works the same as the original Rust code. | let x = 42;
assert!(x == 42);
assert_eq!(x, 42);
| Imports System.Diagnostics
Module Program
Sub Main()
Dim a As Integer = 0
Console.WriteLine("Before")
Trace.Assert(a = 42, "Trace assertion failed: The Answer was incorrect")
Console.WriteLine("After Trace.Assert")
Debug.Assert(a = 42, "Debug assertion failed: The Answer was incorrect")
Console.WriteLine("After Debug.Assert")
End Sub
End Module
|
Transform the following Java implementation into Rust, maintaining the same output and logic. | public class Assertions {
public static void main(String[] args) {
int a = 13;
assert a == 42;
assert a == 42 : "Error message";
}
}
| let x = 42;
assert!(x == 42);
assert_eq!(x, 42);
|
Convert the following code from Rust to Python, ensuring the logic remains intact. | let x = 42;
assert!(x == 42);
assert_eq!(x, 42);
| a = 5
assert a == 42
assert a == 42, "Error message"
|
Translate the given Ada code snippet into C# without altering its behavior. | procedure Array_Collection is
A : array (-3 .. -1) of Integer := (1, 2, 3);
begin
A (-3) := 3;
A (-2) := 2;
A (-1) := 1;
end Array_Collection;
|
int[] intArray = new int[5] { 1, 2, 3, 4, 5 };
int[] intArray = new int[]{ 1, 2, 3, 4, 5 };
int[] intArray = { 1, 2, 3, 4, 5 };
string[] stringArr = new string[5];
stringArr[0] = "string";
|
Transform the following Ada implementation into C, maintaining the same output and logic. | procedure Array_Collection is
A : array (-3 .. -1) of Integer := (1, 2, 3);
begin
A (-3) := 3;
A (-2) := 2;
A (-1) := 1;
end Array_Collection;
| #define cSize( a ) ( sizeof(a)/sizeof(a[0]) )
int ar[10];
ar[0] = 1;
ar[1] = 2;
int* p;
for (p=ar;
p<(ar+cSize(ar));
p++) {
printf("%d\n",*p);
}
|
Translate this program into C++ but keep the logic exactly as in Ada. | procedure Array_Collection is
A : array (-3 .. -1) of Integer := (1, 2, 3);
begin
A (-3) := 3;
A (-2) := 2;
A (-1) := 1;
end Array_Collection;
| int a[5];
a[0] = 1;
int primes[10] = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29 };
#include <string>
std::string strings[4];
|
Port the following code from Ada to Go with equivalent syntax and logic. | procedure Array_Collection is
A : array (-3 .. -1) of Integer := (1, 2, 3);
begin
A (-3) := 3;
A (-2) := 2;
A (-1) := 1;
end Array_Collection;
| package main
import "fmt"
func main() {
var a []interface{}
a = append(a, 3)
a = append(a, "apples", "oranges")
fmt.Println(a)
}
|
Translate this program into Java but keep the logic exactly as in Ada. | procedure Array_Collection is
A : array (-3 .. -1) of Integer := (1, 2, 3);
begin
A (-3) := 3;
A (-2) := 2;
A (-1) := 1;
end Array_Collection;
| List arrayList = new ArrayList();
arrayList.add(new Integer(0));
arrayList.add(0);
List<Integer> myarrlist = new ArrayList<Integer>();
int sum;
for(int i = 0; i < 10; i++) {
myarrlist.add(i);
}
|
Convert this Ada block to Python, preserving its control flow and logic. | procedure Array_Collection is
A : array (-3 .. -1) of Integer := (1, 2, 3);
begin
A (-3) := 3;
A (-2) := 2;
A (-1) := 1;
end Array_Collection;
| collection = [0, '1']
x = collection[0]
collection.append(2)
collection.insert(0, '-1')
y = collection[0]
collection.extend([2,'3'])
collection += [2,'3']
collection[2:6]
len(collection)
collection = (0, 1)
collection[:]
collection[-4:-1]
collection[::2]
collection="some string"
x = collection[::-1]
collection[::2] == "some string"[::2]
collection.__getitem__(slice(0,len(collection),2))
collection = {0: "zero", 1: "one"}
collection['zero'] = 2
collection = set([0, '1'])
|
Change the programming language of this snippet from Ada to VB without modifying what it does. | procedure Array_Collection is
A : array (-3 .. -1) of Integer := (1, 2, 3);
begin
A (-3) := 3;
A (-2) := 2;
A (-1) := 1;
end Array_Collection;
| Dim coll As New Collection
coll.Add "apple"
coll.Add "banana"
|
Convert this Arturo block to C, preserving its control flow and logic. |
arr: ["one" 2 "three" "four"]
arr: arr ++ 5
print arr
| #define cSize( a ) ( sizeof(a)/sizeof(a[0]) )
int ar[10];
ar[0] = 1;
ar[1] = 2;
int* p;
for (p=ar;
p<(ar+cSize(ar));
p++) {
printf("%d\n",*p);
}
|
Maintain the same structure and functionality when rewriting this code in C#. |
arr: ["one" 2 "three" "four"]
arr: arr ++ 5
print arr
|
int[] intArray = new int[5] { 1, 2, 3, 4, 5 };
int[] intArray = new int[]{ 1, 2, 3, 4, 5 };
int[] intArray = { 1, 2, 3, 4, 5 };
string[] stringArr = new string[5];
stringArr[0] = "string";
|
Keep all operations the same but rewrite the snippet in C++. |
arr: ["one" 2 "three" "four"]
arr: arr ++ 5
print arr
| int a[5];
a[0] = 1;
int primes[10] = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29 };
#include <string>
std::string strings[4];
|
Write the same algorithm in Java as shown in this Arturo implementation. |
arr: ["one" 2 "three" "four"]
arr: arr ++ 5
print arr
| List arrayList = new ArrayList();
arrayList.add(new Integer(0));
arrayList.add(0);
List<Integer> myarrlist = new ArrayList<Integer>();
int sum;
for(int i = 0; i < 10; i++) {
myarrlist.add(i);
}
|
Change the programming language of this snippet from Arturo to Python without modifying what it does. |
arr: ["one" 2 "three" "four"]
arr: arr ++ 5
print arr
| collection = [0, '1']
x = collection[0]
collection.append(2)
collection.insert(0, '-1')
y = collection[0]
collection.extend([2,'3'])
collection += [2,'3']
collection[2:6]
len(collection)
collection = (0, 1)
collection[:]
collection[-4:-1]
collection[::2]
collection="some string"
x = collection[::-1]
collection[::2] == "some string"[::2]
collection.__getitem__(slice(0,len(collection),2))
collection = {0: "zero", 1: "one"}
collection['zero'] = 2
collection = set([0, '1'])
|
Generate a VB translation of this Arturo snippet without changing its computational steps. |
arr: ["one" 2 "three" "four"]
arr: arr ++ 5
print arr
| Dim coll As New Collection
coll.Add "apple"
coll.Add "banana"
|
Transform the following Arturo implementation into Go, maintaining the same output and logic. |
arr: ["one" 2 "three" "four"]
arr: arr ++ 5
print arr
| package main
import "fmt"
func main() {
var a []interface{}
a = append(a, 3)
a = append(a, "apples", "oranges")
fmt.Println(a)
}
|
Produce a functionally identical C code for the snippet given in AutoHotKey. | myCol := Object()
mycol.mykey := "my value!"
mycol["mykey"] := "new val!"
MsgBox % mycol.mykey
| #define cSize( a ) ( sizeof(a)/sizeof(a[0]) )
int ar[10];
ar[0] = 1;
ar[1] = 2;
int* p;
for (p=ar;
p<(ar+cSize(ar));
p++) {
printf("%d\n",*p);
}
|
Rewrite the snippet below in C# so it works the same as the original AutoHotKey code. | myCol := Object()
mycol.mykey := "my value!"
mycol["mykey"] := "new val!"
MsgBox % mycol.mykey
|
int[] intArray = new int[5] { 1, 2, 3, 4, 5 };
int[] intArray = new int[]{ 1, 2, 3, 4, 5 };
int[] intArray = { 1, 2, 3, 4, 5 };
string[] stringArr = new string[5];
stringArr[0] = "string";
|
Translate this program into C++ but keep the logic exactly as in AutoHotKey. | myCol := Object()
mycol.mykey := "my value!"
mycol["mykey"] := "new val!"
MsgBox % mycol.mykey
| int a[5];
a[0] = 1;
int primes[10] = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29 };
#include <string>
std::string strings[4];
|
Maintain the same structure and functionality when rewriting this code in Java. | myCol := Object()
mycol.mykey := "my value!"
mycol["mykey"] := "new val!"
MsgBox % mycol.mykey
| List arrayList = new ArrayList();
arrayList.add(new Integer(0));
arrayList.add(0);
List<Integer> myarrlist = new ArrayList<Integer>();
int sum;
for(int i = 0; i < 10; i++) {
myarrlist.add(i);
}
|
Write the same code in Python as shown below in AutoHotKey. | myCol := Object()
mycol.mykey := "my value!"
mycol["mykey"] := "new val!"
MsgBox % mycol.mykey
| collection = [0, '1']
x = collection[0]
collection.append(2)
collection.insert(0, '-1')
y = collection[0]
collection.extend([2,'3'])
collection += [2,'3']
collection[2:6]
len(collection)
collection = (0, 1)
collection[:]
collection[-4:-1]
collection[::2]
collection="some string"
x = collection[::-1]
collection[::2] == "some string"[::2]
collection.__getitem__(slice(0,len(collection),2))
collection = {0: "zero", 1: "one"}
collection['zero'] = 2
collection = set([0, '1'])
|
Keep all operations the same but rewrite the snippet in VB. | myCol := Object()
mycol.mykey := "my value!"
mycol["mykey"] := "new val!"
MsgBox % mycol.mykey
| Dim coll As New Collection
coll.Add "apple"
coll.Add "banana"
|
Port the following code from AutoHotKey to Go with equivalent syntax and logic. | myCol := Object()
mycol.mykey := "my value!"
mycol["mykey"] := "new val!"
MsgBox % mycol.mykey
| package main
import "fmt"
func main() {
var a []interface{}
a = append(a, 3)
a = append(a, "apples", "oranges")
fmt.Println(a)
}
|
Produce a language-to-language conversion: from AWK to C, same semantics. | a[0]="hello"
| #define cSize( a ) ( sizeof(a)/sizeof(a[0]) )
int ar[10];
ar[0] = 1;
ar[1] = 2;
int* p;
for (p=ar;
p<(ar+cSize(ar));
p++) {
printf("%d\n",*p);
}
|
Rewrite the snippet below in C# so it works the same as the original AWK code. | a[0]="hello"
|
int[] intArray = new int[5] { 1, 2, 3, 4, 5 };
int[] intArray = new int[]{ 1, 2, 3, 4, 5 };
int[] intArray = { 1, 2, 3, 4, 5 };
string[] stringArr = new string[5];
stringArr[0] = "string";
|
Generate an equivalent C++ version of this AWK code. | a[0]="hello"
| int a[5];
a[0] = 1;
int primes[10] = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29 };
#include <string>
std::string strings[4];
|
Port the following code from AWK to Java with equivalent syntax and logic. | a[0]="hello"
| List arrayList = new ArrayList();
arrayList.add(new Integer(0));
arrayList.add(0);
List<Integer> myarrlist = new ArrayList<Integer>();
int sum;
for(int i = 0; i < 10; i++) {
myarrlist.add(i);
}
|
Produce a language-to-language conversion: from AWK to Python, same semantics. | a[0]="hello"
| collection = [0, '1']
x = collection[0]
collection.append(2)
collection.insert(0, '-1')
y = collection[0]
collection.extend([2,'3'])
collection += [2,'3']
collection[2:6]
len(collection)
collection = (0, 1)
collection[:]
collection[-4:-1]
collection[::2]
collection="some string"
x = collection[::-1]
collection[::2] == "some string"[::2]
collection.__getitem__(slice(0,len(collection),2))
collection = {0: "zero", 1: "one"}
collection['zero'] = 2
collection = set([0, '1'])
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.