Instruction stringlengths 45 106 | input_code stringlengths 1 13.7k | output_code stringlengths 1 13.7k |
|---|---|---|
Convert the following code from OCaml to PHP, ensuring the logic remains intact. | let rec _read_int() =
try read_int()
with _ ->
print_endline "Please give a cardinal numbers.";
_read_int() ;;
let () =
print_endline "Please give a set limits (two integers):";
let a = _read_int()
and b = _read_int() in
let a, b =
if a < b
then (a, b)
else (b, a)
in
Random.sel... | <?php
session_start();
if(isset($_SESSION['number']))
{
$number = $_SESSION['number'];
}
else
{
$_SESSION['number'] = rand(1,10);
}
if($_POST["guess"]){
$guess = htmlspecialchars($_POST['guess']);
echo $guess . "<br />";
if ($guess < $number)
{
echo "Your guess is too low";
}
elseif(... |
Rewrite the snippet below in PHP so it works the same as the original Perl code. | sub prompt {
my $prompt = shift;
while (1) {
print "\n", $prompt, ": ";
defined($_ = <STDIN>) and !/^\s*q/ or exit;
return $_ if /^\s*\d+\s*$/s;
$prompt = "Please give a non-negative integer";
}
}
my $tgt = int(rand prompt("Hola! Please tell me the upper bound") + 1);
my $tries = 1;
$tries++, print "Yo... | <?php
session_start();
if(isset($_SESSION['number']))
{
$number = $_SESSION['number'];
}
else
{
$_SESSION['number'] = rand(1,10);
}
if($_POST["guess"]){
$guess = htmlspecialchars($_POST['guess']);
echo $guess . "<br />";
if ($guess < $number)
{
echo "Your guess is too low";
}
elseif(... |
Ensure the translated PHP code behaves exactly like the original PowerShell snippet. | function Get-Guess
{
[int]$number = 1..100 | Get-Random
[int]$guess = 0
[int[]]$guesses = @()
Write-Host "Guess a number between 1 and 100" -ForegroundColor Cyan
while ($guess -ne $number)
{
try
{
[int]$guess = Read-Host -Prompt "Guess"
if ($guess -lt $... | <?php
session_start();
if(isset($_SESSION['number']))
{
$number = $_SESSION['number'];
}
else
{
$_SESSION['number'] = rand(1,10);
}
if($_POST["guess"]){
$guess = htmlspecialchars($_POST['guess']);
echo $guess . "<br />";
if ($guess < $number)
{
echo "Your guess is too low";
}
elseif(... |
Rewrite the snippet below in PHP so it works the same as the original Racket code. | #lang racket
(define (guess-number min max)
(define target (+ min (random (- max min -1))))
(printf "I'm thinking of a number between ~a and ~a\n" min max)
(let loop ([prompt "Your guess"])
(printf "~a: " prompt)
(flush-output)
(define guess (read))
(define response
(cond [(not (exact-integ... | <?php
session_start();
if(isset($_SESSION['number']))
{
$number = $_SESSION['number'];
}
else
{
$_SESSION['number'] = rand(1,10);
}
if($_POST["guess"]){
$guess = htmlspecialchars($_POST['guess']);
echo $guess . "<br />";
if ($guess < $number)
{
echo "Your guess is too low";
}
elseif(... |
Port the provided COBOL code into PHP while preserving the original functionality. | IDENTIFICATION DIVISION.
PROGRAM-ID. Guess-With-Feedback.
DATA DIVISION.
LOCAL-STORAGE SECTION.
01 Seed PIC 9(8).
01 Random-Num PIC 99.
01 Guess PIC 99.
PROCEDURE DIVISION.
ACCEPT Seed FROM TIME
COMPUTE Random-Num =
... | <?php
session_start();
if(isset($_SESSION['number']))
{
$number = $_SESSION['number'];
}
else
{
$_SESSION['number'] = rand(1,10);
}
if($_POST["guess"]){
$guess = htmlspecialchars($_POST['guess']);
echo $guess . "<br />";
if ($guess < $number)
{
echo "Your guess is too low";
}
elseif(... |
Rewrite the snippet below in PHP so it works the same as the original REXX code. |
options replace format comments java crossref symbols nobinary
parse arg lo hi .
if lo = '' | lo = '.' then lo = 1
if hi = '' | hi = '.' then hi = 100
if lo > hi then parse (hi lo) lo hi -- make sure lo is < hi
rg = Random()
tries = 0
guessThis = rg.nextInt(hi - lo) + lo
say
say 'Rules: Guess a number between' lo '... | <?php
session_start();
if(isset($_SESSION['number']))
{
$number = $_SESSION['number'];
}
else
{
$_SESSION['number'] = rand(1,10);
}
if($_POST["guess"]){
$guess = htmlspecialchars($_POST['guess']);
echo $guess . "<br />";
if ($guess < $number)
{
echo "Your guess is too low";
}
elseif(... |
Please provide an equivalent version of this Ruby code in PHP. | number = rand(1..10)
puts "Guess the number between 1 and 10"
loop do
begin
user_number = gets.to_s.to_i
if user_number == number
puts "You guessed it."
break
elsif user_number > number
puts "Too high."
else
puts "Too low."
end
rescue ArgumentError
puts "Please en... | <?php
session_start();
if(isset($_SESSION['number']))
{
$number = $_SESSION['number'];
}
else
{
$_SESSION['number'] = rand(1,10);
}
if($_POST["guess"]){
$guess = htmlspecialchars($_POST['guess']);
echo $guess . "<br />";
if ($guess < $number)
{
echo "Your guess is too low";
}
elseif(... |
Write the same algorithm in PHP as shown in this Scala implementation. | import java.util.Random
import java.util.Scanner
val scan = new Scanner(System.in)
val random = new Random
val (from , to) = (1, 100)
val randomNumber = random.nextInt(to - from + 1) + from
var guessedNumber = 0
printf("The number is between %d and %d.\n", from, to)
do {
print("Guess what the number is: ")
guesse... | <?php
session_start();
if(isset($_SESSION['number']))
{
$number = $_SESSION['number'];
}
else
{
$_SESSION['number'] = rand(1,10);
}
if($_POST["guess"]){
$guess = htmlspecialchars($_POST['guess']);
echo $guess . "<br />";
if ($guess < $number)
{
echo "Your guess is too low";
}
elseif(... |
Rewrite the snippet below in PHP so it works the same as the original Swift code. | import Cocoa
var found = false
let randomNum = Int(arc4random_uniform(100) + 1)
println("Guess a number between 1 and 100\n")
while (!found) {
var fh = NSFileHandle.fileHandleWithStandardInput()
println("Enter a number: ")
let data = fh.availableData
let str = NSString(data: data, encoding: NSU... | <?php
session_start();
if(isset($_SESSION['number']))
{
$number = $_SESSION['number'];
}
else
{
$_SESSION['number'] = rand(1,10);
}
if($_POST["guess"]){
$guess = htmlspecialchars($_POST['guess']);
echo $guess . "<br />";
if ($guess < $number)
{
echo "Your guess is too low";
}
elseif(... |
Change the following Tcl code into PHP without altering its purpose. | set from 1
set to 10
set target [expr {int(rand()*($to-$from+1) + $from)}]
puts "I have thought of a number from $from to $to."
puts "Try to guess it!"
while 1 {
puts -nonewline "Enter your guess: "
flush stdout
gets stdin guess
if {![string is int -strict $guess] || $guess < $from || $guess > $to} {
p... | <?php
session_start();
if(isset($_SESSION['number']))
{
$number = $_SESSION['number'];
}
else
{
$_SESSION['number'] = rand(1,10);
}
if($_POST["guess"]){
$guess = htmlspecialchars($_POST['guess']);
echo $guess . "<br />";
if ($guess < $number)
{
echo "Your guess is too low";
}
elseif(... |
Preserve the algorithm and functionality while converting the code from C to Rust. | #include <stdlib.h>
#include <stdio.h>
#include <time.h>
#define lower_limit 0
#define upper_limit 100
int main(){
int number, guess;
srand( time( 0 ) );
number = lower_limit + rand() % (upper_limit - lower_limit + 1);
printf( "Guess the number between %d and %d: ", lower_limit, upper_limit );
while( sca... | use rand::Rng;
use std::cmp::Ordering;
use std::io;
const LOWEST: u32 = 1;
const HIGHEST: u32 = 100;
fn main() {
let secret_number = rand::thread_rng().gen_range(1..101);
println!("I have chosen my number between {} and {}. Guess the number!", LOWEST, HIGHEST);
loop {
println!("Please input your... |
Produce a language-to-language conversion: from C++ to Rust, same semantics. | #include <iostream>
#include <cstdlib>
#include <ctime>
int main()
{
std::srand(std::time(0));
int lower, upper, guess;
std::cout << "Enter lower limit: ";
std::cin >> lower;
std::cout << "Enter upper limit: ";
std::cin >> upper;
int random_number = lower + std::rand() % ((upper + 1) - lowe... | use rand::Rng;
use std::cmp::Ordering;
use std::io;
const LOWEST: u32 = 1;
const HIGHEST: u32 = 100;
fn main() {
let secret_number = rand::thread_rng().gen_range(1..101);
println!("I have chosen my number between {} and {}. Guess the number!", LOWEST, HIGHEST);
loop {
println!("Please input your... |
Maintain the same structure and functionality when rewriting this code in Rust. | using System;
class Program
{
static void Main(string[] args)
{
const int from = 1;
const int to = 10;
int randomNumber = new Random().Next(from, to);
int guessedNumber;
Console.Write("The number is between {0} and {1}. ", from, to);
while (true)
{
... | use rand::Rng;
use std::cmp::Ordering;
use std::io;
const LOWEST: u32 = 1;
const HIGHEST: u32 = 100;
fn main() {
let secret_number = rand::thread_rng().gen_range(1..101);
println!("I have chosen my number between {} and {}. Guess the number!", LOWEST, HIGHEST);
loop {
println!("Please input your... |
Port the following code from Go to Rust with equivalent syntax and logic. | package main
import (
"fmt"
"math/rand"
"time"
)
const lower, upper = 1, 100
func main() {
fmt.Printf("Guess integer number from %d to %d: ", lower, upper)
rand.Seed(time.Now().Unix())
n := rand.Intn(upper-lower+1) + lower
for guess := n; ; {
switch _, err := fmt.Scan(&guess); {
... | use rand::Rng;
use std::cmp::Ordering;
use std::io;
const LOWEST: u32 = 1;
const HIGHEST: u32 = 100;
fn main() {
let secret_number = rand::thread_rng().gen_range(1..101);
println!("I have chosen my number between {} and {}. Guess the number!", LOWEST, HIGHEST);
loop {
println!("Please input your... |
Change the following Rust code into Python without altering its purpose. | use rand::Rng;
use std::cmp::Ordering;
use std::io;
const LOWEST: u32 = 1;
const HIGHEST: u32 = 100;
fn main() {
let secret_number = rand::thread_rng().gen_range(1..101);
println!("I have chosen my number between {} and {}. Guess the number!", LOWEST, HIGHEST);
loop {
println!("Please input your... | import random
inclusive_range = (1, 100)
print("Guess my target number that is between %i and %i (inclusive).\n"
% inclusive_range)
target = random.randint(*inclusive_range)
answer, i = None, 0
while answer != target:
i += 1
txt = input("Your guess(%i): " % i)
try:
answer = int(txt)
exce... |
Write the same algorithm in VB as shown in this Rust implementation. | use rand::Rng;
use std::cmp::Ordering;
use std::io;
const LOWEST: u32 = 1;
const HIGHEST: u32 = 100;
fn main() {
let secret_number = rand::thread_rng().gen_range(1..101);
println!("I have chosen my number between {} and {}. Guess the number!", LOWEST, HIGHEST);
loop {
println!("Please input your... | Sub GuessTheNumberWithFeedback()
Dim Nbc&, Nbp&, m&, n&, c&
Randomize Timer
m = 11
n = 100
Nbc = Int((Rnd * (n - m + 1)) + m)
Do
c = c + 1
Nbp = Application.InputBox("Choose a number between " & m & " and " & n & " : ", "Enter your guess", Type:=1)
Select Case Nbp
... |
Can you help me rewrite this code in Rust instead of Java, keeping it the same logically? | import java.util.Random;
import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
Scanner scan = new Scanner(System.in);
Random random = new Random();
long from = 1;
long to = 100;
int randomNumber = random.nextInt(to - from + 1) + from;
... | use rand::Rng;
use std::cmp::Ordering;
use std::io;
const LOWEST: u32 = 1;
const HIGHEST: u32 = 100;
fn main() {
let secret_number = rand::thread_rng().gen_range(1..101);
println!("I have chosen my number between {} and {}. Guess the number!", LOWEST, HIGHEST);
loop {
println!("Please input your... |
Please provide an equivalent version of this Ada code in C#. | type Point is tagged record
X : Integer := 0;
Y : Integer := 0;
end record;
| struct Point
{
public int x, y;
public Point(int x, int y) {
this.x = x;
this.y = y;
}
}
|
Translate this program into C but keep the logic exactly as in Ada. | type Point is tagged record
X : Integer := 0;
Y : Integer := 0;
end record;
| typedef struct Point
{
int x;
int y;
} Point;
|
Generate an equivalent C++ version of this Ada code. | type Point is tagged record
X : Integer := 0;
Y : Integer := 0;
end record;
| struct Point
{
int x;
int y;
};
|
Generate a Go translation of this Ada snippet without changing its computational steps. | type Point is tagged record
X : Integer := 0;
Y : Integer := 0;
end record;
| type point struct {
x, y float64
}
|
Generate an equivalent Java version of this Ada code. | type Point is tagged record
X : Integer := 0;
Y : Integer := 0;
end record;
| public class Point
{
public int x, y;
public Point() { this(0); }
public Point(int x0) { this(x0,0); }
public Point(int x0, int y0) { x = x0; y = y0; }
public static void main(String args[])
{
Point point = new Point(1,2);
System.out.println("x = " + point.x );
System.out.println("y = " + point... |
Transform the following Ada implementation into Python, maintaining the same output and logic. | type Point is tagged record
X : Integer := 0;
Y : Integer := 0;
end record;
| X, Y = 0, 1
p = (3, 4)
p = [3, 4]
print p[X]
|
Convert the following code from Ada to VB, ensuring the logic remains intact. | type Point is tagged record
X : Integer := 0;
Y : Integer := 0;
end record;
| Type point
x As Integer
y As Integer
End Type
|
Maintain the same structure and functionality when rewriting this code in C. | point := Object()
point.x := 1
point.y := 0
| typedef struct Point
{
int x;
int y;
} Point;
|
Produce a functionally identical C# code for the snippet given in AutoHotKey. | point := Object()
point.x := 1
point.y := 0
| struct Point
{
public int x, y;
public Point(int x, int y) {
this.x = x;
this.y = y;
}
}
|
Rewrite this program in Java while keeping its functionality equivalent to the AutoHotKey version. | point := Object()
point.x := 1
point.y := 0
| public class Point
{
public int x, y;
public Point() { this(0); }
public Point(int x0) { this(x0,0); }
public Point(int x0, int y0) { x = x0; y = y0; }
public static void main(String args[])
{
Point point = new Point(1,2);
System.out.println("x = " + point.x );
System.out.println("y = " + point... |
Produce a functionally identical Python code for the snippet given in AutoHotKey. | point := Object()
point.x := 1
point.y := 0
| X, Y = 0, 1
p = (3, 4)
p = [3, 4]
print p[X]
|
Convert this AWK snippet to C and keep its semantics consistent. | BEGIN {
p["x"]=10
p["y"]=42
z = "ZZ"
p[ z ]=999
p[ 4 ]=5
for (i in p) print( i, ":", p[i] )
}
| typedef struct Point
{
int x;
int y;
} Point;
|
Convert this AWK block to C#, preserving its control flow and logic. | BEGIN {
p["x"]=10
p["y"]=42
z = "ZZ"
p[ z ]=999
p[ 4 ]=5
for (i in p) print( i, ":", p[i] )
}
| struct Point
{
public int x, y;
public Point(int x, int y) {
this.x = x;
this.y = y;
}
}
|
Can you help me rewrite this code in C++ instead of AWK, keeping it the same logically? | BEGIN {
p["x"]=10
p["y"]=42
z = "ZZ"
p[ z ]=999
p[ 4 ]=5
for (i in p) print( i, ":", p[i] )
}
| struct Point
{
int x;
int y;
};
|
Maintain the same structure and functionality when rewriting this code in Java. | BEGIN {
p["x"]=10
p["y"]=42
z = "ZZ"
p[ z ]=999
p[ 4 ]=5
for (i in p) print( i, ":", p[i] )
}
| public class Point
{
public int x, y;
public Point() { this(0); }
public Point(int x0) { this(x0,0); }
public Point(int x0, int y0) { x = x0; y = y0; }
public static void main(String args[])
{
Point point = new Point(1,2);
System.out.println("x = " + point.x );
System.out.println("y = " + point... |
Rewrite this program in Python while keeping its functionality equivalent to the AWK version. | BEGIN {
p["x"]=10
p["y"]=42
z = "ZZ"
p[ z ]=999
p[ 4 ]=5
for (i in p) print( i, ":", p[i] )
}
| X, Y = 0, 1
p = (3, 4)
p = [3, 4]
print p[X]
|
Maintain the same structure and functionality when rewriting this code in VB. | BEGIN {
p["x"]=10
p["y"]=42
z = "ZZ"
p[ z ]=999
p[ 4 ]=5
for (i in p) print( i, ":", p[i] )
}
| Type point
x As Integer
y As Integer
End Type
|
Generate a Go translation of this AWK snippet without changing its computational steps. | BEGIN {
p["x"]=10
p["y"]=42
z = "ZZ"
p[ z ]=999
p[ 4 ]=5
for (i in p) print( i, ":", p[i] )
}
| type point struct {
x, y float64
}
|
Change the programming language of this snippet from BBC_Basic to C# without modifying what it does. | DIM Point{x%, y%}
| struct Point
{
public int x, y;
public Point(int x, int y) {
this.x = x;
this.y = y;
}
}
|
Please provide an equivalent version of this BBC_Basic code in Java. | DIM Point{x%, y%}
| public class Point
{
public int x, y;
public Point() { this(0); }
public Point(int x0) { this(x0,0); }
public Point(int x0, int y0) { x = x0; y = y0; }
public static void main(String args[])
{
Point point = new Point(1,2);
System.out.println("x = " + point.x );
System.out.println("y = " + point... |
Produce a functionally identical Python code for the snippet given in BBC_Basic. | DIM Point{x%, y%}
| X, Y = 0, 1
p = (3, 4)
p = [3, 4]
print p[X]
|
Generate a C# translation of this Clojure snippet without changing its computational steps. | (defrecord Point [x y])
| struct Point
{
public int x, y;
public Point(int x, int y) {
this.x = x;
this.y = y;
}
}
|
Please provide an equivalent version of this Clojure code in Java. | (defrecord Point [x y])
| public class Point
{
public int x, y;
public Point() { this(0); }
public Point(int x0) { this(x0,0); }
public Point(int x0, int y0) { x = x0; y = y0; }
public static void main(String args[])
{
Point point = new Point(1,2);
System.out.println("x = " + point.x );
System.out.println("y = " + point... |
Please provide an equivalent version of this Clojure code in Python. | (defrecord Point [x y])
| X, Y = 0, 1
p = (3, 4)
p = [3, 4]
print p[X]
|
Maintain the same structure and functionality when rewriting this code in C. | (defstructure point
(x (:assert (rationalp x)))
(y (:assert (rationalp y))))
(assign p1 (make-point :x 1 :y 2))
(point-x (@ p1))
(assign p1 (update-point (@ p1) :x 3))
(point-x (@ p1))
(point-p (@ p1))
| typedef struct Point
{
int x;
int y;
} Point;
|
Port the provided Common_Lisp code into C# while preserving the original functionality. | (defstructure point
(x (:assert (rationalp x)))
(y (:assert (rationalp y))))
(assign p1 (make-point :x 1 :y 2))
(point-x (@ p1))
(assign p1 (update-point (@ p1) :x 3))
(point-x (@ p1))
(point-p (@ p1))
| struct Point
{
public int x, y;
public Point(int x, int y) {
this.x = x;
this.y = y;
}
}
|
Produce a functionally identical C++ code for the snippet given in Common_Lisp. | (defstructure point
(x (:assert (rationalp x)))
(y (:assert (rationalp y))))
(assign p1 (make-point :x 1 :y 2))
(point-x (@ p1))
(assign p1 (update-point (@ p1) :x 3))
(point-x (@ p1))
(point-p (@ p1))
| struct Point
{
int x;
int y;
};
|
Rewrite this program in Java while keeping its functionality equivalent to the Common_Lisp version. | (defstructure point
(x (:assert (rationalp x)))
(y (:assert (rationalp y))))
(assign p1 (make-point :x 1 :y 2))
(point-x (@ p1))
(assign p1 (update-point (@ p1) :x 3))
(point-x (@ p1))
(point-p (@ p1))
| public class Point
{
public int x, y;
public Point() { this(0); }
public Point(int x0) { this(x0,0); }
public Point(int x0, int y0) { x = x0; y = y0; }
public static void main(String args[])
{
Point point = new Point(1,2);
System.out.println("x = " + point.x );
System.out.println("y = " + point... |
Convert this Common_Lisp snippet to Python and keep its semantics consistent. | (defstructure point
(x (:assert (rationalp x)))
(y (:assert (rationalp y))))
(assign p1 (make-point :x 1 :y 2))
(point-x (@ p1))
(assign p1 (update-point (@ p1) :x 3))
(point-x (@ p1))
(point-p (@ p1))
| X, Y = 0, 1
p = (3, 4)
p = [3, 4]
print p[X]
|
Write the same algorithm in VB as shown in this Common_Lisp implementation. | (defstructure point
(x (:assert (rationalp x)))
(y (:assert (rationalp y))))
(assign p1 (make-point :x 1 :y 2))
(point-x (@ p1))
(assign p1 (update-point (@ p1) :x 3))
(point-x (@ p1))
(point-p (@ p1))
| Type point
x As Integer
y As Integer
End Type
|
Please provide an equivalent version of this Common_Lisp code in Go. | (defstructure point
(x (:assert (rationalp x)))
(y (:assert (rationalp y))))
(assign p1 (make-point :x 1 :y 2))
(point-x (@ p1))
(assign p1 (update-point (@ p1) :x 3))
(point-x (@ p1))
(point-p (@ p1))
| type point struct {
x, y float64
}
|
Ensure the translated C code behaves exactly like the original D snippet. | void main() {
static struct Point {
int x, y;
}
auto p1 = Point(10, 20);
static struct Pair(T) {
T x, y;
}
auto p2 = Pair!int(3, 5);
auto p3 = Pair!double(3, 5);
static class PointClass {
int x, y;
this(int x_, int y... | typedef struct Point
{
int x;
int y;
} Point;
|
Convert the following code from D to C#, ensuring the logic remains intact. | void main() {
static struct Point {
int x, y;
}
auto p1 = Point(10, 20);
static struct Pair(T) {
T x, y;
}
auto p2 = Pair!int(3, 5);
auto p3 = Pair!double(3, 5);
static class PointClass {
int x, y;
this(int x_, int y... | struct Point
{
public int x, y;
public Point(int x, int y) {
this.x = x;
this.y = y;
}
}
|
Translate the given D code snippet into C++ without altering its behavior. | void main() {
static struct Point {
int x, y;
}
auto p1 = Point(10, 20);
static struct Pair(T) {
T x, y;
}
auto p2 = Pair!int(3, 5);
auto p3 = Pair!double(3, 5);
static class PointClass {
int x, y;
this(int x_, int y... | struct Point
{
int x;
int y;
};
|
Rewrite the snippet below in Java so it works the same as the original D code. | void main() {
static struct Point {
int x, y;
}
auto p1 = Point(10, 20);
static struct Pair(T) {
T x, y;
}
auto p2 = Pair!int(3, 5);
auto p3 = Pair!double(3, 5);
static class PointClass {
int x, y;
this(int x_, int y... | public class Point
{
public int x, y;
public Point() { this(0); }
public Point(int x0) { this(x0,0); }
public Point(int x0, int y0) { x = x0; y = y0; }
public static void main(String args[])
{
Point point = new Point(1,2);
System.out.println("x = " + point.x );
System.out.println("y = " + point... |
Generate an equivalent Python version of this D code. | void main() {
static struct Point {
int x, y;
}
auto p1 = Point(10, 20);
static struct Pair(T) {
T x, y;
}
auto p2 = Pair!int(3, 5);
auto p3 = Pair!double(3, 5);
static class PointClass {
int x, y;
this(int x_, int y... | X, Y = 0, 1
p = (3, 4)
p = [3, 4]
print p[X]
|
Rewrite the snippet below in VB so it works the same as the original D code. | void main() {
static struct Point {
int x, y;
}
auto p1 = Point(10, 20);
static struct Pair(T) {
T x, y;
}
auto p2 = Pair!int(3, 5);
auto p3 = Pair!double(3, 5);
static class PointClass {
int x, y;
this(int x_, int y... | Type point
x As Integer
y As Integer
End Type
|
Write a version of this D function in Go with identical behavior. | void main() {
static struct Point {
int x, y;
}
auto p1 = Point(10, 20);
static struct Pair(T) {
T x, y;
}
auto p2 = Pair!int(3, 5);
auto p3 = Pair!double(3, 5);
static class PointClass {
int x, y;
this(int x_, int y... | type point struct {
x, y float64
}
|
Please provide an equivalent version of this Delphi code in C. | TPoint = record
X: Longint;
Y: Longint;
end;
| typedef struct Point
{
int x;
int y;
} Point;
|
Ensure the translated C# code behaves exactly like the original Delphi snippet. | TPoint = record
X: Longint;
Y: Longint;
end;
| struct Point
{
public int x, y;
public Point(int x, int y) {
this.x = x;
this.y = y;
}
}
|
Produce a functionally identical C++ code for the snippet given in Delphi. | TPoint = record
X: Longint;
Y: Longint;
end;
| struct Point
{
int x;
int y;
};
|
Produce a functionally identical Java code for the snippet given in Delphi. | TPoint = record
X: Longint;
Y: Longint;
end;
| public class Point
{
public int x, y;
public Point() { this(0); }
public Point(int x0) { this(x0,0); }
public Point(int x0, int y0) { x = x0; y = y0; }
public static void main(String args[])
{
Point point = new Point(1,2);
System.out.println("x = " + point.x );
System.out.println("y = " + point... |
Write a version of this Delphi function in Python with identical behavior. | TPoint = record
X: Longint;
Y: Longint;
end;
| X, Y = 0, 1
p = (3, 4)
p = [3, 4]
print p[X]
|
Change the programming language of this snippet from Delphi to VB without modifying what it does. | TPoint = record
X: Longint;
Y: Longint;
end;
| Type point
x As Integer
y As Integer
End Type
|
Convert this Elixir snippet to C and keep its semantics consistent. | iex(1)> defmodule Point do
...(1)> defstruct x: 0, y: 0
...(1)> end
{:module, Point, <<70, 79, 82, ...>>, %Point{x: 0, y: 0}}
iex(2)> origin = %Point{}
%Point{x: 0, y: 0}
iex(3)> pa = %Point{x: 10, y: 20}
%Point{x: 10, y: 20}
iex(4)> pa.x
10
iex(5)> %Point{pa | y: 30}
%Point{x: 10, y: 30}
iex(6)> %Point{x: px, y: py}... | typedef struct Point
{
int x;
int y;
} Point;
|
Write the same code in C# as shown below in Elixir. | iex(1)> defmodule Point do
...(1)> defstruct x: 0, y: 0
...(1)> end
{:module, Point, <<70, 79, 82, ...>>, %Point{x: 0, y: 0}}
iex(2)> origin = %Point{}
%Point{x: 0, y: 0}
iex(3)> pa = %Point{x: 10, y: 20}
%Point{x: 10, y: 20}
iex(4)> pa.x
10
iex(5)> %Point{pa | y: 30}
%Point{x: 10, y: 30}
iex(6)> %Point{x: px, y: py}... | struct Point
{
public int x, y;
public Point(int x, int y) {
this.x = x;
this.y = y;
}
}
|
Write the same algorithm in C++ as shown in this Elixir implementation. | iex(1)> defmodule Point do
...(1)> defstruct x: 0, y: 0
...(1)> end
{:module, Point, <<70, 79, 82, ...>>, %Point{x: 0, y: 0}}
iex(2)> origin = %Point{}
%Point{x: 0, y: 0}
iex(3)> pa = %Point{x: 10, y: 20}
%Point{x: 10, y: 20}
iex(4)> pa.x
10
iex(5)> %Point{pa | y: 30}
%Point{x: 10, y: 30}
iex(6)> %Point{x: px, y: py}... | struct Point
{
int x;
int y;
};
|
Translate the given Elixir code snippet into Java without altering its behavior. | iex(1)> defmodule Point do
...(1)> defstruct x: 0, y: 0
...(1)> end
{:module, Point, <<70, 79, 82, ...>>, %Point{x: 0, y: 0}}
iex(2)> origin = %Point{}
%Point{x: 0, y: 0}
iex(3)> pa = %Point{x: 10, y: 20}
%Point{x: 10, y: 20}
iex(4)> pa.x
10
iex(5)> %Point{pa | y: 30}
%Point{x: 10, y: 30}
iex(6)> %Point{x: px, y: py}... | public class Point
{
public int x, y;
public Point() { this(0); }
public Point(int x0) { this(x0,0); }
public Point(int x0, int y0) { x = x0; y = y0; }
public static void main(String args[])
{
Point point = new Point(1,2);
System.out.println("x = " + point.x );
System.out.println("y = " + point... |
Convert this Elixir snippet to Python and keep its semantics consistent. | iex(1)> defmodule Point do
...(1)> defstruct x: 0, y: 0
...(1)> end
{:module, Point, <<70, 79, 82, ...>>, %Point{x: 0, y: 0}}
iex(2)> origin = %Point{}
%Point{x: 0, y: 0}
iex(3)> pa = %Point{x: 10, y: 20}
%Point{x: 10, y: 20}
iex(4)> pa.x
10
iex(5)> %Point{pa | y: 30}
%Point{x: 10, y: 30}
iex(6)> %Point{x: px, y: py}... | X, Y = 0, 1
p = (3, 4)
p = [3, 4]
print p[X]
|
Convert the following code from Elixir to VB, ensuring the logic remains intact. | iex(1)> defmodule Point do
...(1)> defstruct x: 0, y: 0
...(1)> end
{:module, Point, <<70, 79, 82, ...>>, %Point{x: 0, y: 0}}
iex(2)> origin = %Point{}
%Point{x: 0, y: 0}
iex(3)> pa = %Point{x: 10, y: 20}
%Point{x: 10, y: 20}
iex(4)> pa.x
10
iex(5)> %Point{pa | y: 30}
%Point{x: 10, y: 30}
iex(6)> %Point{x: px, y: py}... | Type point
x As Integer
y As Integer
End Type
|
Rewrite the snippet below in Go so it works the same as the original Elixir code. | iex(1)> defmodule Point do
...(1)> defstruct x: 0, y: 0
...(1)> end
{:module, Point, <<70, 79, 82, ...>>, %Point{x: 0, y: 0}}
iex(2)> origin = %Point{}
%Point{x: 0, y: 0}
iex(3)> pa = %Point{x: 10, y: 20}
%Point{x: 10, y: 20}
iex(4)> pa.x
10
iex(5)> %Point{pa | y: 30}
%Point{x: 10, y: 30}
iex(6)> %Point{x: px, y: py}... | type point struct {
x, y float64
}
|
Generate a C translation of this Erlang snippet without changing its computational steps. | -module(records_test).
-compile(export_all).
-record(point,{x,y}).
test() ->
P1 = #point{x=1.0,y=2.0},
io:fwrite("X: ~f, Y: ~f~n",[P1#point.x,P1#point.y]),
P2 = P1#point{x=3.0},
io:fwrite("X: ~f, Y: ~f~n",[P2#point.x,P2#point.y]).
| typedef struct Point
{
int x;
int y;
} Point;
|
Change the following Erlang code into C# without altering its purpose. | -module(records_test).
-compile(export_all).
-record(point,{x,y}).
test() ->
P1 = #point{x=1.0,y=2.0},
io:fwrite("X: ~f, Y: ~f~n",[P1#point.x,P1#point.y]),
P2 = P1#point{x=3.0},
io:fwrite("X: ~f, Y: ~f~n",[P2#point.x,P2#point.y]).
| struct Point
{
public int x, y;
public Point(int x, int y) {
this.x = x;
this.y = y;
}
}
|
Change the following Erlang code into C++ without altering its purpose. | -module(records_test).
-compile(export_all).
-record(point,{x,y}).
test() ->
P1 = #point{x=1.0,y=2.0},
io:fwrite("X: ~f, Y: ~f~n",[P1#point.x,P1#point.y]),
P2 = P1#point{x=3.0},
io:fwrite("X: ~f, Y: ~f~n",[P2#point.x,P2#point.y]).
| struct Point
{
int x;
int y;
};
|
Write a version of this Erlang function in Java with identical behavior. | -module(records_test).
-compile(export_all).
-record(point,{x,y}).
test() ->
P1 = #point{x=1.0,y=2.0},
io:fwrite("X: ~f, Y: ~f~n",[P1#point.x,P1#point.y]),
P2 = P1#point{x=3.0},
io:fwrite("X: ~f, Y: ~f~n",[P2#point.x,P2#point.y]).
| public class Point
{
public int x, y;
public Point() { this(0); }
public Point(int x0) { this(x0,0); }
public Point(int x0, int y0) { x = x0; y = y0; }
public static void main(String args[])
{
Point point = new Point(1,2);
System.out.println("x = " + point.x );
System.out.println("y = " + point... |
Preserve the algorithm and functionality while converting the code from Erlang to Python. | -module(records_test).
-compile(export_all).
-record(point,{x,y}).
test() ->
P1 = #point{x=1.0,y=2.0},
io:fwrite("X: ~f, Y: ~f~n",[P1#point.x,P1#point.y]),
P2 = P1#point{x=3.0},
io:fwrite("X: ~f, Y: ~f~n",[P2#point.x,P2#point.y]).
| X, Y = 0, 1
p = (3, 4)
p = [3, 4]
print p[X]
|
Produce a language-to-language conversion: from Erlang to VB, same semantics. | -module(records_test).
-compile(export_all).
-record(point,{x,y}).
test() ->
P1 = #point{x=1.0,y=2.0},
io:fwrite("X: ~f, Y: ~f~n",[P1#point.x,P1#point.y]),
P2 = P1#point{x=3.0},
io:fwrite("X: ~f, Y: ~f~n",[P2#point.x,P2#point.y]).
| Type point
x As Integer
y As Integer
End Type
|
Translate the given Erlang code snippet into Go without altering its behavior. | -module(records_test).
-compile(export_all).
-record(point,{x,y}).
test() ->
P1 = #point{x=1.0,y=2.0},
io:fwrite("X: ~f, Y: ~f~n",[P1#point.x,P1#point.y]),
P2 = P1#point{x=3.0},
io:fwrite("X: ~f, Y: ~f~n",[P2#point.x,P2#point.y]).
| type point struct {
x, y float64
}
|
Convert this F# block to C, preserving its control flow and logic. | type Point = { x : int; y : int }
let points = [
{x = 1; y = 1};
{x = 5; y = 5} ]
Seq.iter (fun p -> printfn "%d,%d" p.x p.y) points
| typedef struct Point
{
int x;
int y;
} Point;
|
Maintain the same structure and functionality when rewriting this code in C#. | type Point = { x : int; y : int }
let points = [
{x = 1; y = 1};
{x = 5; y = 5} ]
Seq.iter (fun p -> printfn "%d,%d" p.x p.y) points
| struct Point
{
public int x, y;
public Point(int x, int y) {
this.x = x;
this.y = y;
}
}
|
Write the same algorithm in C++ as shown in this F# implementation. | type Point = { x : int; y : int }
let points = [
{x = 1; y = 1};
{x = 5; y = 5} ]
Seq.iter (fun p -> printfn "%d,%d" p.x p.y) points
| struct Point
{
int x;
int y;
};
|
Write the same code in Java as shown below in F#. | type Point = { x : int; y : int }
let points = [
{x = 1; y = 1};
{x = 5; y = 5} ]
Seq.iter (fun p -> printfn "%d,%d" p.x p.y) points
| public class Point
{
public int x, y;
public Point() { this(0); }
public Point(int x0) { this(x0,0); }
public Point(int x0, int y0) { x = x0; y = y0; }
public static void main(String args[])
{
Point point = new Point(1,2);
System.out.println("x = " + point.x );
System.out.println("y = " + point... |
Can you help me rewrite this code in Python instead of F#, keeping it the same logically? | type Point = { x : int; y : int }
let points = [
{x = 1; y = 1};
{x = 5; y = 5} ]
Seq.iter (fun p -> printfn "%d,%d" p.x p.y) points
| X, Y = 0, 1
p = (3, 4)
p = [3, 4]
print p[X]
|
Produce a language-to-language conversion: from F# to VB, same semantics. | type Point = { x : int; y : int }
let points = [
{x = 1; y = 1};
{x = 5; y = 5} ]
Seq.iter (fun p -> printfn "%d,%d" p.x p.y) points
| Type point
x As Integer
y As Integer
End Type
|
Port the following code from F# to Go with equivalent syntax and logic. | type Point = { x : int; y : int }
let points = [
{x = 1; y = 1};
{x = 5; y = 5} ]
Seq.iter (fun p -> printfn "%d,%d" p.x p.y) points
| type point struct {
x, y float64
}
|
Change the following Factor code into C# without altering its purpose. | TUPLE: point x y ;
| struct Point
{
public int x, y;
public Point(int x, int y) {
this.x = x;
this.y = y;
}
}
|
Port the provided Factor code into Java while preserving the original functionality. | TUPLE: point x y ;
| public class Point
{
public int x, y;
public Point() { this(0); }
public Point(int x0) { this(x0,0); }
public Point(int x0, int y0) { x = x0; y = y0; }
public static void main(String args[])
{
Point point = new Point(1,2);
System.out.println("x = " + point.x );
System.out.println("y = " + point... |
Translate this program into Python but keep the logic exactly as in Factor. | TUPLE: point x y ;
| X, Y = 0, 1
p = (3, 4)
p = [3, 4]
print p[X]
|
Write a version of this Forth function in C with identical behavior. | : pt>x ;
: pt>y CELL+ ;
: .pt dup pt>x @ . pt>y @ . ;
create point 6 , 0 ,
7 point pt>y !
.pt
| typedef struct Point
{
int x;
int y;
} Point;
|
Convert this Forth block to C#, preserving its control flow and logic. | : pt>x ;
: pt>y CELL+ ;
: .pt dup pt>x @ . pt>y @ . ;
create point 6 , 0 ,
7 point pt>y !
.pt
| struct Point
{
public int x, y;
public Point(int x, int y) {
this.x = x;
this.y = y;
}
}
|
Transform the following Forth implementation into C++, maintaining the same output and logic. | : pt>x ;
: pt>y CELL+ ;
: .pt dup pt>x @ . pt>y @ . ;
create point 6 , 0 ,
7 point pt>y !
.pt
| struct Point
{
int x;
int y;
};
|
Convert this Forth snippet to Java and keep its semantics consistent. | : pt>x ;
: pt>y CELL+ ;
: .pt dup pt>x @ . pt>y @ . ;
create point 6 , 0 ,
7 point pt>y !
.pt
| public class Point
{
public int x, y;
public Point() { this(0); }
public Point(int x0) { this(x0,0); }
public Point(int x0, int y0) { x = x0; y = y0; }
public static void main(String args[])
{
Point point = new Point(1,2);
System.out.println("x = " + point.x );
System.out.println("y = " + point... |
Change the following Forth code into Python without altering its purpose. | : pt>x ;
: pt>y CELL+ ;
: .pt dup pt>x @ . pt>y @ . ;
create point 6 , 0 ,
7 point pt>y !
.pt
| X, Y = 0, 1
p = (3, 4)
p = [3, 4]
print p[X]
|
Translate this program into VB but keep the logic exactly as in Forth. | : pt>x ;
: pt>y CELL+ ;
: .pt dup pt>x @ . pt>y @ . ;
create point 6 , 0 ,
7 point pt>y !
.pt
| Type point
x As Integer
y As Integer
End Type
|
Translate this program into Go but keep the logic exactly as in Forth. | : pt>x ;
: pt>y CELL+ ;
: .pt dup pt>x @ . pt>y @ . ;
create point 6 , 0 ,
7 point pt>y !
.pt
| type point struct {
x, y float64
}
|
Convert the following code from Fortran to C#, ensuring the logic remains intact. | program typedemo
type rational
integer :: numerator
integer :: denominator
end type rational
type( rational ), parameter :: zero = rational( 0, 1 )
type( rational ), parameter :: one = rational( 1, 1 )
type( rational ), parameter :... | struct Point
{
public int x, y;
public Point(int x, int y) {
this.x = x;
this.y = y;
}
}
|
Change the following Fortran code into C++ without altering its purpose. | program typedemo
type rational
integer :: numerator
integer :: denominator
end type rational
type( rational ), parameter :: zero = rational( 0, 1 )
type( rational ), parameter :: one = rational( 1, 1 )
type( rational ), parameter :... | struct Point
{
int x;
int y;
};
|
Rewrite the snippet below in C so it works the same as the original Fortran code. | program typedemo
type rational
integer :: numerator
integer :: denominator
end type rational
type( rational ), parameter :: zero = rational( 0, 1 )
type( rational ), parameter :: one = rational( 1, 1 )
type( rational ), parameter :... | typedef struct Point
{
int x;
int y;
} Point;
|
Write the same algorithm in Go as shown in this Fortran implementation. | program typedemo
type rational
integer :: numerator
integer :: denominator
end type rational
type( rational ), parameter :: zero = rational( 0, 1 )
type( rational ), parameter :: one = rational( 1, 1 )
type( rational ), parameter :... | type point struct {
x, y float64
}
|
Generate a Java translation of this Fortran snippet without changing its computational steps. | program typedemo
type rational
integer :: numerator
integer :: denominator
end type rational
type( rational ), parameter :: zero = rational( 0, 1 )
type( rational ), parameter :: one = rational( 1, 1 )
type( rational ), parameter :... | public class Point
{
public int x, y;
public Point() { this(0); }
public Point(int x0) { this(x0,0); }
public Point(int x0, int y0) { x = x0; y = y0; }
public static void main(String args[])
{
Point point = new Point(1,2);
System.out.println("x = " + point.x );
System.out.println("y = " + point... |
Keep all operations the same but rewrite the snippet in Python. | program typedemo
type rational
integer :: numerator
integer :: denominator
end type rational
type( rational ), parameter :: zero = rational( 0, 1 )
type( rational ), parameter :: one = rational( 1, 1 )
type( rational ), parameter :... | X, Y = 0, 1
p = (3, 4)
p = [3, 4]
print p[X]
|
Convert this Fortran block to PHP, preserving its control flow and logic. | program typedemo
type rational
integer :: numerator
integer :: denominator
end type rational
type( rational ), parameter :: zero = rational( 0, 1 )
type( rational ), parameter :: one = rational( 1, 1 )
type( rational ), parameter :... | # Using pack/unpack
$point = pack("ii", 1, 2);
$u = unpack("ix/iy", $point);
echo $x;
echo $y;
list($x,$y) = unpack("ii", $point);
echo $x;
echo $y;
|
Preserve the algorithm and functionality while converting the code from Groovy to C. | class Point {
int x
int y
Point(int x = 0, int y = 0) { this.x = x; this.y = y }
String toString() { "{x:${x}, y:${y}}" }
}
| typedef struct Point
{
int x;
int y;
} Point;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.