Instruction stringlengths 45 106 | input_code stringlengths 1 13.7k | output_code stringlengths 1 13.7k |
|---|---|---|
Write a version of this Haskell function in PHP with identical behavior. | import Text.Printf
main =
printf "%09.3f" 7.125
| echo str_pad(7.125, 9, '0', STR_PAD_LEFT);
|
Generate a PHP translation of this Icon snippet without changing its computational steps. | link printf
procedure main()
every r := &pi | -r | 100-r do {
write(r," <=== no printf")
every p := "|%r|" | "|%9.3r|" | "|%-9.3r|" | "|%0.3r|" | "|%e|" | "|%d|" do
write(sprintf(p,r)," <=== sprintf ",p)
}
end
| echo str_pad(7.125, 9, '0', STR_PAD_LEFT);
|
Translate the given J code snippet into PHP without altering its behavior. | 'r<0>9.3' (8!:2) 7.125
00007.125
| echo str_pad(7.125, 9, '0', STR_PAD_LEFT);
|
Transform the following Julia implementation into PHP, maintaining the same output and logic. | using Printf
test = [7.125, [rand()*10^rand(0:4) for i in 1:9]]
println("Formatting some numbers with the @sprintf macro (using \"%09.3f\"):")
for i in test
println(@sprintf " %09.3f" i)
end
using Formatting
println()
println("The same thing using the Formatting package:")
fe = FormatExpr(" {1:09.3f}")
for i in test
printfmtln(fe, i)
end
| echo str_pad(7.125, 9, '0', STR_PAD_LEFT);
|
Write the same algorithm in PHP as shown in this Lua implementation. | function digits(n) return math.floor(math.log(n) / math.log(10))+1 end
function fixedprint(num, digs)
for i = 1, digs - digits(num) do
io.write"0"
end
print(num)
end
fixedprint(7.125, 5)
| echo str_pad(7.125, 9, '0', STR_PAD_LEFT);
|
Write the same algorithm in PHP as shown in this Mathematica implementation. | StringTake["000000" <> ToString[7.125], -9]
00007.125
| echo str_pad(7.125, 9, '0', STR_PAD_LEFT);
|
Generate a PHP translation of this Nim snippet without changing its computational steps. | import strformat
const r = 7.125
echo r
echo fmt"{-r:9.3f}"
echo fmt"{r:9.3f}"
echo fmt"{-r:09.3f}"
echo fmt"{r:09.3f}"
| echo str_pad(7.125, 9, '0', STR_PAD_LEFT);
|
Write the same code in PHP as shown below in Pascal. | procedure writeInFixedFormat(n: real);
const
wholeNumberPlaces = 5;
fractionalPlaces = 3;
zeroDigit = '0';
negative = '-';
var
signPresent: boolean;
i: integer;
begin
signPresent := n < 0.0;
if signPresent then
begin
write(negative);
n := abs(n);
end;
i := wholeNumberPlaces;
if n > 0 then
begin
i := i - trunc(ln(n) / ln(10));
end;
for i := i - 1 downto succ(ord(signPresent)) do
begin
write(zeroDigit);
end;
write(n:0:fractionalPlaces);
end;
| echo str_pad(7.125, 9, '0', STR_PAD_LEFT);
|
Write the same algorithm in PHP as shown in this R implementation. | > sprintf("%f", pi)
[1] "3.141593"
> sprintf("%.3f", pi)
[1] "3.142"
> sprintf("%1.0f", pi)
[1] "3"
> sprintf("%5.1f", pi)
[1] " 3.1"
> sprintf("%05.1f", pi)
[1] "003.1"
> sprintf("%+f", pi)
[1] "+3.141593"
> sprintf("% f", pi)
[1] " 3.141593"
> sprintf("%-10f", pi)
[1] "3.141593 "
> sprintf("%e", pi)
[1] "3.141593e+00"
> sprintf("%E", pi)
[1] "3.141593E+00"
> sprintf("%g", pi)
[1] "3.14159"
> sprintf("%g", 1e6 * pi)
[1] "3.14159e+06"
> sprintf("%.9g", 1e6 * pi)
[1] "3141592.65"
> sprintf("%G", 1e-6 * pi)
[1] "3.14159E-06"
| echo str_pad(7.125, 9, '0', STR_PAD_LEFT);
|
Keep all operations the same but rewrite the snippet in PHP. | -> (displayln (~a 7.125 #:width 9 #:align 'right #:pad-string "0"))
00007.125
| echo str_pad(7.125, 9, '0', STR_PAD_LEFT);
|
Generate a PHP translation of this COBOL snippet without changing its computational steps. | IDENTIFICATION DIVISION.
PROGRAM-ID. NUMERIC-OUTPUT-PROGRAM.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-EXAMPLE.
05 X PIC 9(5)V9(3).
PROCEDURE DIVISION.
MOVE 7.125 TO X.
DISPLAY X UPON CONSOLE.
STOP RUN.
| echo str_pad(7.125, 9, '0', STR_PAD_LEFT);
|
Can you help me rewrite this code in PHP instead of REXX, keeping it the same logically? |
options replace format comments java crossref savelog symbols binary
import java.text.MessageFormat
sevenPointOneTwoFive = double 7.125
-- using NetRexx Built-In Functions (BIFs)
say Rexx(sevenPointOneTwoFive).format(5, 3).changestr(' ', '0')
-- using Java library constructs
System.out.printf('%09.3f\n', [Double(sevenPointOneTwoFive)])
say MessageFormat.format('{0,number,#00000.###}', [Double(sevenPointOneTwoFive)])
return
| echo str_pad(7.125, 9, '0', STR_PAD_LEFT);
|
Produce a language-to-language conversion: from Ruby to PHP, same semantics. | r = 7.125
printf " %9.3f\n", r
printf " %09.3f\n", r
printf " %09.3f\n", -r
printf " %+09.3f\n", r
puts " %9.3f" % r
puts " %09.3f" % r
puts " %09.3f" % -r
puts " %+09.3f" % r
| echo str_pad(7.125, 9, '0', STR_PAD_LEFT);
|
Rewrite the snippet below in PHP so it works the same as the original Scala code. |
fun main(args: Array<String>) {
val num = 7.125
println("%09.3f".format(num))
}
| echo str_pad(7.125, 9, '0', STR_PAD_LEFT);
|
Change the programming language of this snippet from C to Rust without modifying what it does. | #include <stdio.h>
main(){
float r=7.125;
printf(" %9.3f\n",-r);
printf(" %9.3f\n",r);
printf(" %-9.3f\n",r);
printf(" %09.3f\n",-r);
printf(" %09.3f\n",r);
printf(" %-09.3f\n",r);
return 0;
}
| fn main() {
let x = 7.125;
println!("{:9}", x);
println!("{:09}", x);
println!("{:9}", -x);
println!("{:09}", -x);
}
|
Convert this C++ block to Rust, preserving its control flow and logic. | #include <iostream>
#include <iomanip>
int main()
{
std::cout << std::setfill('0') << std::setw(9) << std::fixed << std::setprecision(3) << 7.125 << std::endl;
return 0;
}
| fn main() {
let x = 7.125;
println!("{:9}", x);
println!("{:09}", x);
println!("{:9}", -x);
println!("{:09}", -x);
}
|
Convert this C# snippet to Rust and keep its semantics consistent. | class Program
{
static void Main(string[] args)
{
float myNumbers = 7.125F;
string strnumber = Convert.ToString(myNumbers);
Console.WriteLine(strnumber.PadLeft(9, '0'));
Console.ReadLine();
}
}
| fn main() {
let x = 7.125;
println!("{:9}", x);
println!("{:09}", x);
println!("{:9}", -x);
println!("{:09}", -x);
}
|
Keep all operations the same but rewrite the snippet in Rust. | public class Printing{
public static void main(String[] args){
double value = 7.125;
System.out.printf("%09.3f",value);
System.out.println(String.format("%09.3f",value));
}
}
| fn main() {
let x = 7.125;
println!("{:9}", x);
println!("{:09}", x);
println!("{:9}", -x);
println!("{:09}", -x);
}
|
Please provide an equivalent version of this Go code in Rust. | fmt.Printf("%09.3f", 7.125)
| fn main() {
let x = 7.125;
println!("{:9}", x);
println!("{:09}", x);
println!("{:9}", -x);
println!("{:09}", -x);
}
|
Can you help me rewrite this code in Python instead of Rust, keeping it the same logically? | fn main() {
let x = 7.125;
println!("{:9}", x);
println!("{:09}", x);
println!("{:9}", -x);
println!("{:09}", -x);
}
| from math import pi, exp
r = exp(pi)-pi
print r
print "e=%e f=%f g=%g G=%G s=%s r=%r!"%(r,r,r,r,r,r)
print "e=%9.4e f=%9.4f g=%9.4g!"%(-r,-r,-r)
print "e=%9.4e f=%9.4f g=%9.4g!"%(r,r,r)
print "e=%-9.4e f=%-9.4f g=%-9.4g!"%(r,r,r)
print "e=%09.4e f=%09.4f g=%09.4g!"%(-r,-r,-r)
print "e=%09.4e f=%09.4f g=%09.4g!"%(r,r,r)
print "e=%-09.4e f=%-09.4f g=%-09.4g!"%(r,r,r)
|
Rewrite this program in VB while keeping its functionality equivalent to the Rust version. | fn main() {
let x = 7.125;
println!("{:9}", x);
println!("{:09}", x);
println!("{:9}", -x);
println!("{:09}", -x);
}
| Option Explicit
Sub Main()
Debug.Print fFormat(13, 2, 1230.3333)
Debug.Print fFormat(2, 13, 1230.3333)
Debug.Print fFormat(10, 5, 0.3333)
Debug.Print fFormat(13, 2, 1230)
End Sub
Private Function fFormat(NbInt As Integer, NbDec As Integer, Nb As Double) As String
Dim u As String, v As String, i As Integer
u = CStr(Nb)
i = InStr(u, Application.DecimalSeparator)
If i > 0 Then
v = Mid(u, i + 1)
u = Left(u, i - 1)
fFormat = Right(String(NbInt, "0") & u, NbInt) & Application.DecimalSeparator & Left(v & String(NbDec, "0"), NbDec)
Else
fFormat = Right(String(NbInt, "0") & u, NbInt) & Application.DecimalSeparator & String(NbDec, "0")
End If
End Function
|
Transform the following Ada implementation into C#, maintaining the same output and logic. | type Link;
type Link_Access is access Link;
type Link is record
Next : Link_Access := null;
Prev : Link_Access := null;
Data : Integer;
end record;
| class Link
{
public int Item { get; set; }
public Link Prev { get; set; }
public Link Next { get; set; }
public Link(int item, Link prev = null, Link next = null) {
Item = item;
Prev = prev;
Next = next;
}
}
|
Convert the following code from Ada to C, ensuring the logic remains intact. | type Link;
type Link_Access is access Link;
type Link is record
Next : Link_Access := null;
Prev : Link_Access := null;
Data : Integer;
end record;
| struct Node
{
struct Node *next;
struct Node *prev;
void *data;
};
|
Write the same algorithm in C++ as shown in this Ada implementation. | type Link;
type Link_Access is access Link;
type Link is record
Next : Link_Access := null;
Prev : Link_Access := null;
Data : Integer;
end record;
| template <typename T>
struct Node
{
Node* next;
Node* prev;
T data;
};
|
Can you help me rewrite this code in Go instead of Ada, keeping it the same logically? | type Link;
type Link_Access is access Link;
type Link is record
Next : Link_Access := null;
Prev : Link_Access := null;
Data : Integer;
end record;
| type dlNode struct {
string
next, prev *dlNode
}
|
Can you help me rewrite this code in Java instead of Ada, keeping it the same logically? | type Link;
type Link_Access is access Link;
type Link is record
Next : Link_Access := null;
Prev : Link_Access := null;
Data : Integer;
end record;
| public class Node<T> {
private T element;
private Node<T> next, prev;
public Node<T>(){
next = prev = element = null;
}
public Node<T>(Node<T> n, Node<T> p, T elem){
next = n;
prev = p;
element = elem;
}
public void setNext(Node<T> n){
next = n;
}
public Node<T> getNext(){
return next;
}
public void setElem(T elem){
element = elem;
}
public T getElem(){
return element;
}
public void setNext(Node<T> n){
next = n;
}
public Node<T> setPrev(Node<T> p){
prev = p;
}
public getPrev(){
return prev;
}
}
|
Change the programming language of this snippet from Ada to Python without modifying what it does. | type Link;
type Link_Access is access Link;
type Link is record
Next : Link_Access := null;
Prev : Link_Access := null;
Data : Integer;
end record;
| class Node(object):
def __init__(self, data = None, prev = None, next = None):
self.prev = prev
self.next = next
self.data = data
def __str__(self):
return str(self.data)
def __repr__(self):
return repr(self.data)
def iter_forward(self):
c = self
while c != None:
yield c
c = c.next
def iter_backward(self):
c = self
while c != None:
yield c
c = c.prev
|
Change the programming language of this snippet from Ada to VB without modifying what it does. | type Link;
type Link_Access is access Link;
type Link is record
Next : Link_Access := null;
Prev : Link_Access := null;
Data : Integer;
end record;
| Public Class Node(Of T)
Public Value As T
Public [Next] As Node(Of T)
Public Previous As Node(Of T)
End Class
|
Generate an equivalent C version of this BBC_Basic code. | DIM node{pPrev%, pNext%, iData%}
| struct Node
{
struct Node *next;
struct Node *prev;
void *data;
};
|
Write the same algorithm in C# as shown in this BBC_Basic implementation. | DIM node{pPrev%, pNext%, iData%}
| class Link
{
public int Item { get; set; }
public Link Prev { get; set; }
public Link Next { get; set; }
public Link(int item, Link prev = null, Link next = null) {
Item = item;
Prev = prev;
Next = next;
}
}
|
Please provide an equivalent version of this BBC_Basic code in C++. | DIM node{pPrev%, pNext%, iData%}
| template <typename T>
struct Node
{
Node* next;
Node* prev;
T data;
};
|
Preserve the algorithm and functionality while converting the code from BBC_Basic to Java. | DIM node{pPrev%, pNext%, iData%}
| public class Node<T> {
private T element;
private Node<T> next, prev;
public Node<T>(){
next = prev = element = null;
}
public Node<T>(Node<T> n, Node<T> p, T elem){
next = n;
prev = p;
element = elem;
}
public void setNext(Node<T> n){
next = n;
}
public Node<T> getNext(){
return next;
}
public void setElem(T elem){
element = elem;
}
public T getElem(){
return element;
}
public void setNext(Node<T> n){
next = n;
}
public Node<T> setPrev(Node<T> p){
prev = p;
}
public getPrev(){
return prev;
}
}
|
Produce a language-to-language conversion: from BBC_Basic to Python, same semantics. | DIM node{pPrev%, pNext%, iData%}
| class Node(object):
def __init__(self, data = None, prev = None, next = None):
self.prev = prev
self.next = next
self.data = data
def __str__(self):
return str(self.data)
def __repr__(self):
return repr(self.data)
def iter_forward(self):
c = self
while c != None:
yield c
c = c.next
def iter_backward(self):
c = self
while c != None:
yield c
c = c.prev
|
Convert this BBC_Basic snippet to VB and keep its semantics consistent. | DIM node{pPrev%, pNext%, iData%}
| Public Class Node(Of T)
Public Value As T
Public [Next] As Node(Of T)
Public Previous As Node(Of T)
End Class
|
Keep all operations the same but rewrite the snippet in C. | (defrecord Node [prev next data])
(defn new-node [prev next data]
(Node. (ref prev) (ref next) data))
| struct Node
{
struct Node *next;
struct Node *prev;
void *data;
};
|
Preserve the algorithm and functionality while converting the code from Clojure to C#. | (defrecord Node [prev next data])
(defn new-node [prev next data]
(Node. (ref prev) (ref next) data))
| class Link
{
public int Item { get; set; }
public Link Prev { get; set; }
public Link Next { get; set; }
public Link(int item, Link prev = null, Link next = null) {
Item = item;
Prev = prev;
Next = next;
}
}
|
Convert the following code from Clojure to C++, ensuring the logic remains intact. | (defrecord Node [prev next data])
(defn new-node [prev next data]
(Node. (ref prev) (ref next) data))
| template <typename T>
struct Node
{
Node* next;
Node* prev;
T data;
};
|
Rewrite the snippet below in Java so it works the same as the original Clojure code. | (defrecord Node [prev next data])
(defn new-node [prev next data]
(Node. (ref prev) (ref next) data))
| public class Node<T> {
private T element;
private Node<T> next, prev;
public Node<T>(){
next = prev = element = null;
}
public Node<T>(Node<T> n, Node<T> p, T elem){
next = n;
prev = p;
element = elem;
}
public void setNext(Node<T> n){
next = n;
}
public Node<T> getNext(){
return next;
}
public void setElem(T elem){
element = elem;
}
public T getElem(){
return element;
}
public void setNext(Node<T> n){
next = n;
}
public Node<T> setPrev(Node<T> p){
prev = p;
}
public getPrev(){
return prev;
}
}
|
Translate this program into Python but keep the logic exactly as in Clojure. | (defrecord Node [prev next data])
(defn new-node [prev next data]
(Node. (ref prev) (ref next) data))
| class Node(object):
def __init__(self, data = None, prev = None, next = None):
self.prev = prev
self.next = next
self.data = data
def __str__(self):
return str(self.data)
def __repr__(self):
return repr(self.data)
def iter_forward(self):
c = self
while c != None:
yield c
c = c.next
def iter_backward(self):
c = self
while c != None:
yield c
c = c.prev
|
Rewrite this program in VB while keeping its functionality equivalent to the Clojure version. | (defrecord Node [prev next data])
(defn new-node [prev next data]
(Node. (ref prev) (ref next) data))
| Public Class Node(Of T)
Public Value As T
Public [Next] As Node(Of T)
Public Previous As Node(Of T)
End Class
|
Produce a functionally identical Go code for the snippet given in Clojure. | (defrecord Node [prev next data])
(defn new-node [prev next data]
(Node. (ref prev) (ref next) data))
| type dlNode struct {
string
next, prev *dlNode
}
|
Translate this program into C but keep the logic exactly as in Common_Lisp. | (defstruct dlist head tail)
(defstruct dlink content prev next)
| struct Node
{
struct Node *next;
struct Node *prev;
void *data;
};
|
Port the provided Common_Lisp code into C# while preserving the original functionality. | (defstruct dlist head tail)
(defstruct dlink content prev next)
| class Link
{
public int Item { get; set; }
public Link Prev { get; set; }
public Link Next { get; set; }
public Link(int item, Link prev = null, Link next = null) {
Item = item;
Prev = prev;
Next = next;
}
}
|
Convert this Common_Lisp snippet to C++ and keep its semantics consistent. | (defstruct dlist head tail)
(defstruct dlink content prev next)
| template <typename T>
struct Node
{
Node* next;
Node* prev;
T data;
};
|
Write a version of this Common_Lisp function in Java with identical behavior. | (defstruct dlist head tail)
(defstruct dlink content prev next)
| public class Node<T> {
private T element;
private Node<T> next, prev;
public Node<T>(){
next = prev = element = null;
}
public Node<T>(Node<T> n, Node<T> p, T elem){
next = n;
prev = p;
element = elem;
}
public void setNext(Node<T> n){
next = n;
}
public Node<T> getNext(){
return next;
}
public void setElem(T elem){
element = elem;
}
public T getElem(){
return element;
}
public void setNext(Node<T> n){
next = n;
}
public Node<T> setPrev(Node<T> p){
prev = p;
}
public getPrev(){
return prev;
}
}
|
Change the programming language of this snippet from Common_Lisp to Python without modifying what it does. | (defstruct dlist head tail)
(defstruct dlink content prev next)
| class Node(object):
def __init__(self, data = None, prev = None, next = None):
self.prev = prev
self.next = next
self.data = data
def __str__(self):
return str(self.data)
def __repr__(self):
return repr(self.data)
def iter_forward(self):
c = self
while c != None:
yield c
c = c.next
def iter_backward(self):
c = self
while c != None:
yield c
c = c.prev
|
Generate a VB translation of this Common_Lisp snippet without changing its computational steps. | (defstruct dlist head tail)
(defstruct dlink content prev next)
| Public Class Node(Of T)
Public Value As T
Public [Next] As Node(Of T)
Public Previous As Node(Of T)
End Class
|
Change the programming language of this snippet from D to C without modifying what it does. | struct Node(T) {
T data;
typeof(this)* prev, next;
}
void main() {
alias N = Node!int;
N* n = new N(10);
}
| struct Node
{
struct Node *next;
struct Node *prev;
void *data;
};
|
Rewrite the snippet below in C# so it works the same as the original D code. | struct Node(T) {
T data;
typeof(this)* prev, next;
}
void main() {
alias N = Node!int;
N* n = new N(10);
}
| class Link
{
public int Item { get; set; }
public Link Prev { get; set; }
public Link Next { get; set; }
public Link(int item, Link prev = null, Link next = null) {
Item = item;
Prev = prev;
Next = next;
}
}
|
Write a version of this D function in C++ with identical behavior. | struct Node(T) {
T data;
typeof(this)* prev, next;
}
void main() {
alias N = Node!int;
N* n = new N(10);
}
| template <typename T>
struct Node
{
Node* next;
Node* prev;
T data;
};
|
Produce a language-to-language conversion: from D to Java, same semantics. | struct Node(T) {
T data;
typeof(this)* prev, next;
}
void main() {
alias N = Node!int;
N* n = new N(10);
}
| public class Node<T> {
private T element;
private Node<T> next, prev;
public Node<T>(){
next = prev = element = null;
}
public Node<T>(Node<T> n, Node<T> p, T elem){
next = n;
prev = p;
element = elem;
}
public void setNext(Node<T> n){
next = n;
}
public Node<T> getNext(){
return next;
}
public void setElem(T elem){
element = elem;
}
public T getElem(){
return element;
}
public void setNext(Node<T> n){
next = n;
}
public Node<T> setPrev(Node<T> p){
prev = p;
}
public getPrev(){
return prev;
}
}
|
Generate a Python translation of this D snippet without changing its computational steps. | struct Node(T) {
T data;
typeof(this)* prev, next;
}
void main() {
alias N = Node!int;
N* n = new N(10);
}
| class Node(object):
def __init__(self, data = None, prev = None, next = None):
self.prev = prev
self.next = next
self.data = data
def __str__(self):
return str(self.data)
def __repr__(self):
return repr(self.data)
def iter_forward(self):
c = self
while c != None:
yield c
c = c.next
def iter_backward(self):
c = self
while c != None:
yield c
c = c.prev
|
Write the same code in VB as shown below in D. | struct Node(T) {
T data;
typeof(this)* prev, next;
}
void main() {
alias N = Node!int;
N* n = new N(10);
}
| Public Class Node(Of T)
Public Value As T
Public [Next] As Node(Of T)
Public Previous As Node(Of T)
End Class
|
Translate the given D code snippet into Go without altering its behavior. | struct Node(T) {
T data;
typeof(this)* prev, next;
}
void main() {
alias N = Node!int;
N* n = new N(10);
}
| type dlNode struct {
string
next, prev *dlNode
}
|
Rewrite this program in C while keeping its functionality equivalent to the Erlang version. | new( Data ) -> erlang:spawn( fun() -> loop( Data, noprevious, nonext ) end ).
| struct Node
{
struct Node *next;
struct Node *prev;
void *data;
};
|
Generate an equivalent C# version of this Erlang code. | new( Data ) -> erlang:spawn( fun() -> loop( Data, noprevious, nonext ) end ).
| class Link
{
public int Item { get; set; }
public Link Prev { get; set; }
public Link Next { get; set; }
public Link(int item, Link prev = null, Link next = null) {
Item = item;
Prev = prev;
Next = next;
}
}
|
Port the following code from Erlang to C++ with equivalent syntax and logic. | new( Data ) -> erlang:spawn( fun() -> loop( Data, noprevious, nonext ) end ).
| template <typename T>
struct Node
{
Node* next;
Node* prev;
T data;
};
|
Port the provided Erlang code into Java while preserving the original functionality. | new( Data ) -> erlang:spawn( fun() -> loop( Data, noprevious, nonext ) end ).
| public class Node<T> {
private T element;
private Node<T> next, prev;
public Node<T>(){
next = prev = element = null;
}
public Node<T>(Node<T> n, Node<T> p, T elem){
next = n;
prev = p;
element = elem;
}
public void setNext(Node<T> n){
next = n;
}
public Node<T> getNext(){
return next;
}
public void setElem(T elem){
element = elem;
}
public T getElem(){
return element;
}
public void setNext(Node<T> n){
next = n;
}
public Node<T> setPrev(Node<T> p){
prev = p;
}
public getPrev(){
return prev;
}
}
|
Rewrite this program in Python while keeping its functionality equivalent to the Erlang version. | new( Data ) -> erlang:spawn( fun() -> loop( Data, noprevious, nonext ) end ).
| class Node(object):
def __init__(self, data = None, prev = None, next = None):
self.prev = prev
self.next = next
self.data = data
def __str__(self):
return str(self.data)
def __repr__(self):
return repr(self.data)
def iter_forward(self):
c = self
while c != None:
yield c
c = c.next
def iter_backward(self):
c = self
while c != None:
yield c
c = c.prev
|
Port the following code from Erlang to VB with equivalent syntax and logic. | new( Data ) -> erlang:spawn( fun() -> loop( Data, noprevious, nonext ) end ).
| Public Class Node(Of T)
Public Value As T
Public [Next] As Node(Of T)
Public Previous As Node(Of T)
End Class
|
Please provide an equivalent version of this Erlang code in Go. | new( Data ) -> erlang:spawn( fun() -> loop( Data, noprevious, nonext ) end ).
| type dlNode struct {
string
next, prev *dlNode
}
|
Translate this program into C but keep the logic exactly as in F#. | type 'a DLElm = {
mutable prev: 'a DLElm option
data: 'a
mutable next: 'a DLElm option
}
| struct Node
{
struct Node *next;
struct Node *prev;
void *data;
};
|
Convert this F# block to C#, preserving its control flow and logic. | type 'a DLElm = {
mutable prev: 'a DLElm option
data: 'a
mutable next: 'a DLElm option
}
| class Link
{
public int Item { get; set; }
public Link Prev { get; set; }
public Link Next { get; set; }
public Link(int item, Link prev = null, Link next = null) {
Item = item;
Prev = prev;
Next = next;
}
}
|
Change the programming language of this snippet from F# to C++ without modifying what it does. | type 'a DLElm = {
mutable prev: 'a DLElm option
data: 'a
mutable next: 'a DLElm option
}
| template <typename T>
struct Node
{
Node* next;
Node* prev;
T data;
};
|
Convert this F# snippet to Java and keep its semantics consistent. | type 'a DLElm = {
mutable prev: 'a DLElm option
data: 'a
mutable next: 'a DLElm option
}
| public class Node<T> {
private T element;
private Node<T> next, prev;
public Node<T>(){
next = prev = element = null;
}
public Node<T>(Node<T> n, Node<T> p, T elem){
next = n;
prev = p;
element = elem;
}
public void setNext(Node<T> n){
next = n;
}
public Node<T> getNext(){
return next;
}
public void setElem(T elem){
element = elem;
}
public T getElem(){
return element;
}
public void setNext(Node<T> n){
next = n;
}
public Node<T> setPrev(Node<T> p){
prev = p;
}
public getPrev(){
return prev;
}
}
|
Can you help me rewrite this code in Python instead of F#, keeping it the same logically? | type 'a DLElm = {
mutable prev: 'a DLElm option
data: 'a
mutable next: 'a DLElm option
}
| class Node(object):
def __init__(self, data = None, prev = None, next = None):
self.prev = prev
self.next = next
self.data = data
def __str__(self):
return str(self.data)
def __repr__(self):
return repr(self.data)
def iter_forward(self):
c = self
while c != None:
yield c
c = c.next
def iter_backward(self):
c = self
while c != None:
yield c
c = c.prev
|
Produce a language-to-language conversion: from F# to VB, same semantics. | type 'a DLElm = {
mutable prev: 'a DLElm option
data: 'a
mutable next: 'a DLElm option
}
| Public Class Node(Of T)
Public Value As T
Public [Next] As Node(Of T)
Public Previous As Node(Of T)
End Class
|
Port the following code from F# to Go with equivalent syntax and logic. | type 'a DLElm = {
mutable prev: 'a DLElm option
data: 'a
mutable next: 'a DLElm option
}
| type dlNode struct {
string
next, prev *dlNode
}
|
Change the following Factor code into C without altering its purpose. | TUPLE: node data next prev ;
| struct Node
{
struct Node *next;
struct Node *prev;
void *data;
};
|
Produce a functionally identical C# code for the snippet given in Factor. | TUPLE: node data next prev ;
| class Link
{
public int Item { get; set; }
public Link Prev { get; set; }
public Link Next { get; set; }
public Link(int item, Link prev = null, Link next = null) {
Item = item;
Prev = prev;
Next = next;
}
}
|
Change the programming language of this snippet from Factor to C++ without modifying what it does. | TUPLE: node data next prev ;
| template <typename T>
struct Node
{
Node* next;
Node* prev;
T data;
};
|
Translate the given Factor code snippet into Java without altering its behavior. | TUPLE: node data next prev ;
| public class Node<T> {
private T element;
private Node<T> next, prev;
public Node<T>(){
next = prev = element = null;
}
public Node<T>(Node<T> n, Node<T> p, T elem){
next = n;
prev = p;
element = elem;
}
public void setNext(Node<T> n){
next = n;
}
public Node<T> getNext(){
return next;
}
public void setElem(T elem){
element = elem;
}
public T getElem(){
return element;
}
public void setNext(Node<T> n){
next = n;
}
public Node<T> setPrev(Node<T> p){
prev = p;
}
public getPrev(){
return prev;
}
}
|
Write the same code in Python as shown below in Factor. | TUPLE: node data next prev ;
| class Node(object):
def __init__(self, data = None, prev = None, next = None):
self.prev = prev
self.next = next
self.data = data
def __str__(self):
return str(self.data)
def __repr__(self):
return repr(self.data)
def iter_forward(self):
c = self
while c != None:
yield c
c = c.next
def iter_backward(self):
c = self
while c != None:
yield c
c = c.prev
|
Please provide an equivalent version of this Factor code in VB. | TUPLE: node data next prev ;
| Public Class Node(Of T)
Public Value As T
Public [Next] As Node(Of T)
Public Previous As Node(Of T)
End Class
|
Translate this program into C# but keep the logic exactly as in Fortran. | type node
real :: data
type(node), pointer :: next => null(), previous => null()
end type node
type( node ), target :: head
| class Link
{
public int Item { get; set; }
public Link Prev { get; set; }
public Link Next { get; set; }
public Link(int item, Link prev = null, Link next = null) {
Item = item;
Prev = prev;
Next = next;
}
}
|
Please provide an equivalent version of this Fortran code in C++. | type node
real :: data
type(node), pointer :: next => null(), previous => null()
end type node
type( node ), target :: head
| template <typename T>
struct Node
{
Node* next;
Node* prev;
T data;
};
|
Transform the following Fortran implementation into C, maintaining the same output and logic. | type node
real :: data
type(node), pointer :: next => null(), previous => null()
end type node
type( node ), target :: head
| struct Node
{
struct Node *next;
struct Node *prev;
void *data;
};
|
Can you help me rewrite this code in Java instead of Fortran, keeping it the same logically? | type node
real :: data
type(node), pointer :: next => null(), previous => null()
end type node
type( node ), target :: head
| public class Node<T> {
private T element;
private Node<T> next, prev;
public Node<T>(){
next = prev = element = null;
}
public Node<T>(Node<T> n, Node<T> p, T elem){
next = n;
prev = p;
element = elem;
}
public void setNext(Node<T> n){
next = n;
}
public Node<T> getNext(){
return next;
}
public void setElem(T elem){
element = elem;
}
public T getElem(){
return element;
}
public void setNext(Node<T> n){
next = n;
}
public Node<T> setPrev(Node<T> p){
prev = p;
}
public getPrev(){
return prev;
}
}
|
Change the following Fortran code into Python without altering its purpose. | type node
real :: data
type(node), pointer :: next => null(), previous => null()
end type node
type( node ), target :: head
| class Node(object):
def __init__(self, data = None, prev = None, next = None):
self.prev = prev
self.next = next
self.data = data
def __str__(self):
return str(self.data)
def __repr__(self):
return repr(self.data)
def iter_forward(self):
c = self
while c != None:
yield c
c = c.next
def iter_backward(self):
c = self
while c != None:
yield c
c = c.prev
|
Ensure the translated VB code behaves exactly like the original Fortran snippet. | type node
real :: data
type(node), pointer :: next => null(), previous => null()
end type node
type( node ), target :: head
| Public Class Node(Of T)
Public Value As T
Public [Next] As Node(Of T)
Public Previous As Node(Of T)
End Class
|
Transform the following Haskell implementation into C, maintaining the same output and logic. | data DList a = Leaf | Node (DList a) a (DList a)
updateLeft _ Leaf = Leaf
updateLeft Leaf (Node _ v r) = Node Leaf v r
updateLeft new@(Node nl _ _) (Node _ v r) = current
where current = Node prev v r
prev = updateLeft nl new
updateRight _ Leaf = Leaf
updateRight Leaf (Node l v _) = Node l v Leaf
updateRight new@(Node _ _ nr) (Node l v _) = current
where current = Node l v next
next = updateRight nr new
| struct Node
{
struct Node *next;
struct Node *prev;
void *data;
};
|
Port the provided Haskell code into C# while preserving the original functionality. | data DList a = Leaf | Node (DList a) a (DList a)
updateLeft _ Leaf = Leaf
updateLeft Leaf (Node _ v r) = Node Leaf v r
updateLeft new@(Node nl _ _) (Node _ v r) = current
where current = Node prev v r
prev = updateLeft nl new
updateRight _ Leaf = Leaf
updateRight Leaf (Node l v _) = Node l v Leaf
updateRight new@(Node _ _ nr) (Node l v _) = current
where current = Node l v next
next = updateRight nr new
| class Link
{
public int Item { get; set; }
public Link Prev { get; set; }
public Link Next { get; set; }
public Link(int item, Link prev = null, Link next = null) {
Item = item;
Prev = prev;
Next = next;
}
}
|
Generate a C++ translation of this Haskell snippet without changing its computational steps. | data DList a = Leaf | Node (DList a) a (DList a)
updateLeft _ Leaf = Leaf
updateLeft Leaf (Node _ v r) = Node Leaf v r
updateLeft new@(Node nl _ _) (Node _ v r) = current
where current = Node prev v r
prev = updateLeft nl new
updateRight _ Leaf = Leaf
updateRight Leaf (Node l v _) = Node l v Leaf
updateRight new@(Node _ _ nr) (Node l v _) = current
where current = Node l v next
next = updateRight nr new
| template <typename T>
struct Node
{
Node* next;
Node* prev;
T data;
};
|
Port the provided Haskell code into Java while preserving the original functionality. | data DList a = Leaf | Node (DList a) a (DList a)
updateLeft _ Leaf = Leaf
updateLeft Leaf (Node _ v r) = Node Leaf v r
updateLeft new@(Node nl _ _) (Node _ v r) = current
where current = Node prev v r
prev = updateLeft nl new
updateRight _ Leaf = Leaf
updateRight Leaf (Node l v _) = Node l v Leaf
updateRight new@(Node _ _ nr) (Node l v _) = current
where current = Node l v next
next = updateRight nr new
| public class Node<T> {
private T element;
private Node<T> next, prev;
public Node<T>(){
next = prev = element = null;
}
public Node<T>(Node<T> n, Node<T> p, T elem){
next = n;
prev = p;
element = elem;
}
public void setNext(Node<T> n){
next = n;
}
public Node<T> getNext(){
return next;
}
public void setElem(T elem){
element = elem;
}
public T getElem(){
return element;
}
public void setNext(Node<T> n){
next = n;
}
public Node<T> setPrev(Node<T> p){
prev = p;
}
public getPrev(){
return prev;
}
}
|
Ensure the translated Python code behaves exactly like the original Haskell snippet. | data DList a = Leaf | Node (DList a) a (DList a)
updateLeft _ Leaf = Leaf
updateLeft Leaf (Node _ v r) = Node Leaf v r
updateLeft new@(Node nl _ _) (Node _ v r) = current
where current = Node prev v r
prev = updateLeft nl new
updateRight _ Leaf = Leaf
updateRight Leaf (Node l v _) = Node l v Leaf
updateRight new@(Node _ _ nr) (Node l v _) = current
where current = Node l v next
next = updateRight nr new
| class Node(object):
def __init__(self, data = None, prev = None, next = None):
self.prev = prev
self.next = next
self.data = data
def __str__(self):
return str(self.data)
def __repr__(self):
return repr(self.data)
def iter_forward(self):
c = self
while c != None:
yield c
c = c.next
def iter_backward(self):
c = self
while c != None:
yield c
c = c.prev
|
Change the programming language of this snippet from Haskell to VB without modifying what it does. | data DList a = Leaf | Node (DList a) a (DList a)
updateLeft _ Leaf = Leaf
updateLeft Leaf (Node _ v r) = Node Leaf v r
updateLeft new@(Node nl _ _) (Node _ v r) = current
where current = Node prev v r
prev = updateLeft nl new
updateRight _ Leaf = Leaf
updateRight Leaf (Node l v _) = Node l v Leaf
updateRight new@(Node _ _ nr) (Node l v _) = current
where current = Node l v next
next = updateRight nr new
| Public Class Node(Of T)
Public Value As T
Public [Next] As Node(Of T)
Public Previous As Node(Of T)
End Class
|
Ensure the translated Go code behaves exactly like the original Haskell snippet. | data DList a = Leaf | Node (DList a) a (DList a)
updateLeft _ Leaf = Leaf
updateLeft Leaf (Node _ v r) = Node Leaf v r
updateLeft new@(Node nl _ _) (Node _ v r) = current
where current = Node prev v r
prev = updateLeft nl new
updateRight _ Leaf = Leaf
updateRight Leaf (Node l v _) = Node l v Leaf
updateRight new@(Node _ _ nr) (Node l v _) = current
where current = Node l v next
next = updateRight nr new
| type dlNode struct {
string
next, prev *dlNode
}
|
Convert this J block to C, preserving its control flow and logic. | coclass'DoublyLinkedListElement'
create=:3 :0
this=:coname''
'predecessor successor data'=:y
successor__predecessor=: predecessor__successor=: this
)
| struct Node
{
struct Node *next;
struct Node *prev;
void *data;
};
|
Translate the given J code snippet into C# without altering its behavior. | coclass'DoublyLinkedListElement'
create=:3 :0
this=:coname''
'predecessor successor data'=:y
successor__predecessor=: predecessor__successor=: this
)
| class Link
{
public int Item { get; set; }
public Link Prev { get; set; }
public Link Next { get; set; }
public Link(int item, Link prev = null, Link next = null) {
Item = item;
Prev = prev;
Next = next;
}
}
|
Translate this program into C++ but keep the logic exactly as in J. | coclass'DoublyLinkedListElement'
create=:3 :0
this=:coname''
'predecessor successor data'=:y
successor__predecessor=: predecessor__successor=: this
)
| template <typename T>
struct Node
{
Node* next;
Node* prev;
T data;
};
|
Rewrite this program in Java while keeping its functionality equivalent to the J version. | coclass'DoublyLinkedListElement'
create=:3 :0
this=:coname''
'predecessor successor data'=:y
successor__predecessor=: predecessor__successor=: this
)
| public class Node<T> {
private T element;
private Node<T> next, prev;
public Node<T>(){
next = prev = element = null;
}
public Node<T>(Node<T> n, Node<T> p, T elem){
next = n;
prev = p;
element = elem;
}
public void setNext(Node<T> n){
next = n;
}
public Node<T> getNext(){
return next;
}
public void setElem(T elem){
element = elem;
}
public T getElem(){
return element;
}
public void setNext(Node<T> n){
next = n;
}
public Node<T> setPrev(Node<T> p){
prev = p;
}
public getPrev(){
return prev;
}
}
|
Maintain the same structure and functionality when rewriting this code in Python. | coclass'DoublyLinkedListElement'
create=:3 :0
this=:coname''
'predecessor successor data'=:y
successor__predecessor=: predecessor__successor=: this
)
| class Node(object):
def __init__(self, data = None, prev = None, next = None):
self.prev = prev
self.next = next
self.data = data
def __str__(self):
return str(self.data)
def __repr__(self):
return repr(self.data)
def iter_forward(self):
c = self
while c != None:
yield c
c = c.next
def iter_backward(self):
c = self
while c != None:
yield c
c = c.prev
|
Convert this J block to VB, preserving its control flow and logic. | coclass'DoublyLinkedListElement'
create=:3 :0
this=:coname''
'predecessor successor data'=:y
successor__predecessor=: predecessor__successor=: this
)
| Public Class Node(Of T)
Public Value As T
Public [Next] As Node(Of T)
Public Previous As Node(Of T)
End Class
|
Change the following J code into Go without altering its purpose. | coclass'DoublyLinkedListElement'
create=:3 :0
this=:coname''
'predecessor successor data'=:y
successor__predecessor=: predecessor__successor=: this
)
| type dlNode struct {
string
next, prev *dlNode
}
|
Generate a C translation of this Julia snippet without changing its computational steps. | abstract type AbstractNode{T} end
struct EmptyNode{T} <: AbstractNode{T} end
mutable struct Node{T} <: AbstractNode{T}
value::T
pred::AbstractNode{T}
succ::AbstractNode{T}
end
| struct Node
{
struct Node *next;
struct Node *prev;
void *data;
};
|
Convert this Julia snippet to C# and keep its semantics consistent. | abstract type AbstractNode{T} end
struct EmptyNode{T} <: AbstractNode{T} end
mutable struct Node{T} <: AbstractNode{T}
value::T
pred::AbstractNode{T}
succ::AbstractNode{T}
end
| class Link
{
public int Item { get; set; }
public Link Prev { get; set; }
public Link Next { get; set; }
public Link(int item, Link prev = null, Link next = null) {
Item = item;
Prev = prev;
Next = next;
}
}
|
Convert this Julia block to C++, preserving its control flow and logic. | abstract type AbstractNode{T} end
struct EmptyNode{T} <: AbstractNode{T} end
mutable struct Node{T} <: AbstractNode{T}
value::T
pred::AbstractNode{T}
succ::AbstractNode{T}
end
| template <typename T>
struct Node
{
Node* next;
Node* prev;
T data;
};
|
Rewrite this program in Java while keeping its functionality equivalent to the Julia version. | abstract type AbstractNode{T} end
struct EmptyNode{T} <: AbstractNode{T} end
mutable struct Node{T} <: AbstractNode{T}
value::T
pred::AbstractNode{T}
succ::AbstractNode{T}
end
| public class Node<T> {
private T element;
private Node<T> next, prev;
public Node<T>(){
next = prev = element = null;
}
public Node<T>(Node<T> n, Node<T> p, T elem){
next = n;
prev = p;
element = elem;
}
public void setNext(Node<T> n){
next = n;
}
public Node<T> getNext(){
return next;
}
public void setElem(T elem){
element = elem;
}
public T getElem(){
return element;
}
public void setNext(Node<T> n){
next = n;
}
public Node<T> setPrev(Node<T> p){
prev = p;
}
public getPrev(){
return prev;
}
}
|
Translate the given Julia code snippet into Python without altering its behavior. | abstract type AbstractNode{T} end
struct EmptyNode{T} <: AbstractNode{T} end
mutable struct Node{T} <: AbstractNode{T}
value::T
pred::AbstractNode{T}
succ::AbstractNode{T}
end
| class Node(object):
def __init__(self, data = None, prev = None, next = None):
self.prev = prev
self.next = next
self.data = data
def __str__(self):
return str(self.data)
def __repr__(self):
return repr(self.data)
def iter_forward(self):
c = self
while c != None:
yield c
c = c.next
def iter_backward(self):
c = self
while c != None:
yield c
c = c.prev
|
Convert this Julia block to VB, preserving its control flow and logic. | abstract type AbstractNode{T} end
struct EmptyNode{T} <: AbstractNode{T} end
mutable struct Node{T} <: AbstractNode{T}
value::T
pred::AbstractNode{T}
succ::AbstractNode{T}
end
| Public Class Node(Of T)
Public Value As T
Public [Next] As Node(Of T)
Public Previous As Node(Of T)
End Class
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.