Instruction stringlengths 45 106 | input_code stringlengths 1 13.7k | output_code stringlengths 1 13.7k |
|---|---|---|
Change the following AutoHotKey code into Python without altering its purpose. | a = 1
a_next = b
b = 2
b_next = c
c = 3
traverse("a")
return
traverse(element)
{
MsgBox % element . "= " . %element%
name := element . "_next"
while, %name%
{
element := %name%
msgbox % %name% . "= " . %element%
name := %name% . "_next"
}
}
| for node in lst:
print node.value
|
Write the same code in VB as shown below in AutoHotKey. | a = 1
a_next = b
b = 2
b_next = c
c = 3
traverse("a")
return
traverse(element)
{
MsgBox % element . "= " . %element%
name := element . "_next"
while, %name%
{
element := %name%
msgbox % %name% . "= " . %element%
name := %name% . "_next"
}
}
| Private Sub Iterate(ByVal list As LinkedList(Of Integer))
Dim node = list.First
Do Until node Is Nothing
node = node.Next
Loop
End Sub
|
Write the same code in Go as shown below in AutoHotKey. | a = 1
a_next = b
b = 2
b_next = c
c = 3
traverse("a")
return
traverse(element)
{
MsgBox % element . "= " . %element%
name := element . "_next"
while, %name%
{
element := %name%
msgbox % %name% . "= " . %element%
name := %name% . "_next"
}
}
| start := &Ele{"tacos", nil}
end := start.Append("burritos")
end = end.Append("fajitas")
end = end.Append("enchilatas")
for iter := start; iter != nil; iter = iter.Next {
fmt.Println(iter)
}
|
Translate this program into C but keep the logic exactly as in BBC_Basic. | DIM node{pNext%, iData%}
DIM a{} = node{}, b{} = node{}, c{} = node{}
a.pNext% = b{}
a.iData% = 123
b.iData% = 789
c.iData% = 456
PROCinsert(a{}, c{})
PRINT "Traverse list:"
pnode% = a{}
REPEAT
!(^node{}+4) = pnode%
PRINT node.iData%
pnode% = node.pNext%
UNTIL pnode% = 0
END
DEF PROCinsert(here{}, new{})
new.pNext% = here.pNext%
here.pNext% = new{}
ENDPROC
| struct link *first;
struct link *iter;
for(iter = first; iter != NULL; iter = iter->next) {
}
|
Write the same algorithm in C# as shown in this BBC_Basic implementation. | DIM node{pNext%, iData%}
DIM a{} = node{}, b{} = node{}, c{} = node{}
a.pNext% = b{}
a.iData% = 123
b.iData% = 789
c.iData% = 456
PROCinsert(a{}, c{})
PRINT "Traverse list:"
pnode% = a{}
REPEAT
!(^node{}+4) = pnode%
PRINT node.iData%
pnode% = node.pNext%
UNTIL pnode% = 0
END
DEF PROCinsert(here{}, new{})
new.pNext% = here.pNext%
here.pNext% = new{}
ENDPROC
| var current = [head of list to traverse]
while(current != null)
{
current = current.Next;
}
|
Port the provided BBC_Basic code into C++ while preserving the original functionality. | DIM node{pNext%, iData%}
DIM a{} = node{}, b{} = node{}, c{} = node{}
a.pNext% = b{}
a.iData% = 123
b.iData% = 789
c.iData% = 456
PROCinsert(a{}, c{})
PRINT "Traverse list:"
pnode% = a{}
REPEAT
!(^node{}+4) = pnode%
PRINT node.iData%
pnode% = node.pNext%
UNTIL pnode% = 0
END
DEF PROCinsert(here{}, new{})
new.pNext% = here.pNext%
here.pNext% = new{}
ENDPROC
| #include <iostream>
#include <forward_list>
int main()
{
std::forward_list<int> list{1, 2, 3, 4, 5};
for (int e : list)
std::cout << e << std::endl;
}
|
Keep all operations the same but rewrite the snippet in Java. | DIM node{pNext%, iData%}
DIM a{} = node{}, b{} = node{}, c{} = node{}
a.pNext% = b{}
a.iData% = 123
b.iData% = 789
c.iData% = 456
PROCinsert(a{}, c{})
PRINT "Traverse list:"
pnode% = a{}
REPEAT
!(^node{}+4) = pnode%
PRINT node.iData%
pnode% = node.pNext%
UNTIL pnode% = 0
END
DEF PROCinsert(here{}, new{})
new.pNext% = here.pNext%
here.pNext% = new{}
ENDPROC
| LinkedList<Type> list = new LinkedList<Type>();
for(Type i: list){
System.out.println(i);
}
|
Transform the following BBC_Basic implementation into Python, maintaining the same output and logic. | DIM node{pNext%, iData%}
DIM a{} = node{}, b{} = node{}, c{} = node{}
a.pNext% = b{}
a.iData% = 123
b.iData% = 789
c.iData% = 456
PROCinsert(a{}, c{})
PRINT "Traverse list:"
pnode% = a{}
REPEAT
!(^node{}+4) = pnode%
PRINT node.iData%
pnode% = node.pNext%
UNTIL pnode% = 0
END
DEF PROCinsert(here{}, new{})
new.pNext% = here.pNext%
here.pNext% = new{}
ENDPROC
| for node in lst:
print node.value
|
Port the provided BBC_Basic code into VB while preserving the original functionality. | DIM node{pNext%, iData%}
DIM a{} = node{}, b{} = node{}, c{} = node{}
a.pNext% = b{}
a.iData% = 123
b.iData% = 789
c.iData% = 456
PROCinsert(a{}, c{})
PRINT "Traverse list:"
pnode% = a{}
REPEAT
!(^node{}+4) = pnode%
PRINT node.iData%
pnode% = node.pNext%
UNTIL pnode% = 0
END
DEF PROCinsert(here{}, new{})
new.pNext% = here.pNext%
here.pNext% = new{}
ENDPROC
| Private Sub Iterate(ByVal list As LinkedList(Of Integer))
Dim node = list.First
Do Until node Is Nothing
node = node.Next
Loop
End Sub
|
Can you help me rewrite this code in Go instead of BBC_Basic, keeping it the same logically? | DIM node{pNext%, iData%}
DIM a{} = node{}, b{} = node{}, c{} = node{}
a.pNext% = b{}
a.iData% = 123
b.iData% = 789
c.iData% = 456
PROCinsert(a{}, c{})
PRINT "Traverse list:"
pnode% = a{}
REPEAT
!(^node{}+4) = pnode%
PRINT node.iData%
pnode% = node.pNext%
UNTIL pnode% = 0
END
DEF PROCinsert(here{}, new{})
new.pNext% = here.pNext%
here.pNext% = new{}
ENDPROC
| start := &Ele{"tacos", nil}
end := start.Append("burritos")
end = end.Append("fajitas")
end = end.Append("enchilatas")
for iter := start; iter != nil; iter = iter.Next {
fmt.Println(iter)
}
|
Translate this program into C but keep the logic exactly as in Common_Lisp. | (defun traverse (xs)
(if (endp xs)
(cw "End.~%")
(prog2$ (cw "~x0~%" (first xs))
(traverse (rest xs)))))
| struct link *first;
struct link *iter;
for(iter = first; iter != NULL; iter = iter->next) {
}
|
Produce a functionally identical C# code for the snippet given in Common_Lisp. | (defun traverse (xs)
(if (endp xs)
(cw "End.~%")
(prog2$ (cw "~x0~%" (first xs))
(traverse (rest xs)))))
| var current = [head of list to traverse]
while(current != null)
{
current = current.Next;
}
|
Preserve the algorithm and functionality while converting the code from Common_Lisp to C++. | (defun traverse (xs)
(if (endp xs)
(cw "End.~%")
(prog2$ (cw "~x0~%" (first xs))
(traverse (rest xs)))))
| #include <iostream>
#include <forward_list>
int main()
{
std::forward_list<int> list{1, 2, 3, 4, 5};
for (int e : list)
std::cout << e << std::endl;
}
|
Convert this Common_Lisp block to Java, preserving its control flow and logic. | (defun traverse (xs)
(if (endp xs)
(cw "End.~%")
(prog2$ (cw "~x0~%" (first xs))
(traverse (rest xs)))))
| LinkedList<Type> list = new LinkedList<Type>();
for(Type i: list){
System.out.println(i);
}
|
Generate an equivalent Python version of this Common_Lisp code. | (defun traverse (xs)
(if (endp xs)
(cw "End.~%")
(prog2$ (cw "~x0~%" (first xs))
(traverse (rest xs)))))
| for node in lst:
print node.value
|
Port the following code from Common_Lisp to VB with equivalent syntax and logic. | (defun traverse (xs)
(if (endp xs)
(cw "End.~%")
(prog2$ (cw "~x0~%" (first xs))
(traverse (rest xs)))))
| Private Sub Iterate(ByVal list As LinkedList(Of Integer))
Dim node = list.First
Do Until node Is Nothing
node = node.Next
Loop
End Sub
|
Rewrite the snippet below in Go so it works the same as the original Common_Lisp code. | (defun traverse (xs)
(if (endp xs)
(cw "End.~%")
(prog2$ (cw "~x0~%" (first xs))
(traverse (rest xs)))))
| start := &Ele{"tacos", nil}
end := start.Append("burritos")
end = end.Append("fajitas")
end = end.Append("enchilatas")
for iter := start; iter != nil; iter = iter.Next {
fmt.Println(iter)
}
|
Ensure the translated C code behaves exactly like the original D snippet. | struct SLinkedNode(T) {
T data;
typeof(this)* next;
}
void main() {
import std.stdio;
alias N = SLinkedNode!int;
auto lh = new N(1, new N(2, new N(3, new N(4))));
for (auto p = lh; p; p = p.next)
write(p.data, " ");
writeln();
}
| struct link *first;
struct link *iter;
for(iter = first; iter != NULL; iter = iter->next) {
}
|
Write a version of this D function in C# with identical behavior. | struct SLinkedNode(T) {
T data;
typeof(this)* next;
}
void main() {
import std.stdio;
alias N = SLinkedNode!int;
auto lh = new N(1, new N(2, new N(3, new N(4))));
for (auto p = lh; p; p = p.next)
write(p.data, " ");
writeln();
}
| var current = [head of list to traverse]
while(current != null)
{
current = current.Next;
}
|
Produce a functionally identical C++ code for the snippet given in D. | struct SLinkedNode(T) {
T data;
typeof(this)* next;
}
void main() {
import std.stdio;
alias N = SLinkedNode!int;
auto lh = new N(1, new N(2, new N(3, new N(4))));
for (auto p = lh; p; p = p.next)
write(p.data, " ");
writeln();
}
| #include <iostream>
#include <forward_list>
int main()
{
std::forward_list<int> list{1, 2, 3, 4, 5};
for (int e : list)
std::cout << e << std::endl;
}
|
Change the following D code into Java without altering its purpose. | struct SLinkedNode(T) {
T data;
typeof(this)* next;
}
void main() {
import std.stdio;
alias N = SLinkedNode!int;
auto lh = new N(1, new N(2, new N(3, new N(4))));
for (auto p = lh; p; p = p.next)
write(p.data, " ");
writeln();
}
| LinkedList<Type> list = new LinkedList<Type>();
for(Type i: list){
System.out.println(i);
}
|
Write a version of this D function in Python with identical behavior. | struct SLinkedNode(T) {
T data;
typeof(this)* next;
}
void main() {
import std.stdio;
alias N = SLinkedNode!int;
auto lh = new N(1, new N(2, new N(3, new N(4))));
for (auto p = lh; p; p = p.next)
write(p.data, " ");
writeln();
}
| for node in lst:
print node.value
|
Preserve the algorithm and functionality while converting the code from D to VB. | struct SLinkedNode(T) {
T data;
typeof(this)* next;
}
void main() {
import std.stdio;
alias N = SLinkedNode!int;
auto lh = new N(1, new N(2, new N(3, new N(4))));
for (auto p = lh; p; p = p.next)
write(p.data, " ");
writeln();
}
| Private Sub Iterate(ByVal list As LinkedList(Of Integer))
Dim node = list.First
Do Until node Is Nothing
node = node.Next
Loop
End Sub
|
Rewrite the snippet below in Go so it works the same as the original D code. | struct SLinkedNode(T) {
T data;
typeof(this)* next;
}
void main() {
import std.stdio;
alias N = SLinkedNode!int;
auto lh = new N(1, new N(2, new N(3, new N(4))));
for (auto p = lh; p; p = p.next)
write(p.data, " ");
writeln();
}
| start := &Ele{"tacos", nil}
end := start.Append("burritos")
end = end.Append("fajitas")
end = end.Append("enchilatas")
for iter := start; iter != nil; iter = iter.Next {
fmt.Println(iter)
}
|
Rewrite the snippet below in C so it works the same as the original Delphi code. | uses system ;
type
plist = ^List ;
List = record
data : pointer ;
next : pList ;
end;
begin
while not (pList^.Next = NIL) do pList := pList^.Next ;
end;
| struct link *first;
struct link *iter;
for(iter = first; iter != NULL; iter = iter->next) {
}
|
Transform the following Delphi implementation into C#, maintaining the same output and logic. | uses system ;
type
plist = ^List ;
List = record
data : pointer ;
next : pList ;
end;
begin
while not (pList^.Next = NIL) do pList := pList^.Next ;
end;
| var current = [head of list to traverse]
while(current != null)
{
current = current.Next;
}
|
Translate this program into C++ but keep the logic exactly as in Delphi. | uses system ;
type
plist = ^List ;
List = record
data : pointer ;
next : pList ;
end;
begin
while not (pList^.Next = NIL) do pList := pList^.Next ;
end;
| #include <iostream>
#include <forward_list>
int main()
{
std::forward_list<int> list{1, 2, 3, 4, 5};
for (int e : list)
std::cout << e << std::endl;
}
|
Convert this Delphi snippet to Java and keep its semantics consistent. | uses system ;
type
plist = ^List ;
List = record
data : pointer ;
next : pList ;
end;
begin
while not (pList^.Next = NIL) do pList := pList^.Next ;
end;
| LinkedList<Type> list = new LinkedList<Type>();
for(Type i: list){
System.out.println(i);
}
|
Write the same algorithm in Python as shown in this Delphi implementation. | uses system ;
type
plist = ^List ;
List = record
data : pointer ;
next : pList ;
end;
begin
while not (pList^.Next = NIL) do pList := pList^.Next ;
end;
| for node in lst:
print node.value
|
Rewrite the snippet below in VB so it works the same as the original Delphi code. | uses system ;
type
plist = ^List ;
List = record
data : pointer ;
next : pList ;
end;
begin
while not (pList^.Next = NIL) do pList := pList^.Next ;
end;
| Private Sub Iterate(ByVal list As LinkedList(Of Integer))
Dim node = list.First
Do Until node Is Nothing
node = node.Next
Loop
End Sub
|
Rewrite this program in Go while keeping its functionality equivalent to the Delphi version. | uses system ;
type
plist = ^List ;
List = record
data : pointer ;
next : pList ;
end;
begin
while not (pList^.Next = NIL) do pList := pList^.Next ;
end;
| start := &Ele{"tacos", nil}
end := start.Append("burritos")
end = end.Append("fajitas")
end = end.Append("enchilatas")
for iter := start; iter != nil; iter = iter.Next {
fmt.Println(iter)
}
|
Can you help me rewrite this code in C instead of Factor, keeping it the same logically? | : list-each ( linked-list quot: ( data -- ) -- )
[ [ data>> ] dip call ]
[ [ next>> ] dip over [ list-each ] [ 2drop ] if ] 2bi ; inline recursive
SYMBOLS: A B C ;
A <linked-list>
[ C <linked-list> list-insert ] keep
[ B <linked-list> list-insert ] keep
[ . ] list-each
| struct link *first;
struct link *iter;
for(iter = first; iter != NULL; iter = iter->next) {
}
|
Generate a C# translation of this Factor snippet without changing its computational steps. | : list-each ( linked-list quot: ( data -- ) -- )
[ [ data>> ] dip call ]
[ [ next>> ] dip over [ list-each ] [ 2drop ] if ] 2bi ; inline recursive
SYMBOLS: A B C ;
A <linked-list>
[ C <linked-list> list-insert ] keep
[ B <linked-list> list-insert ] keep
[ . ] list-each
| var current = [head of list to traverse]
while(current != null)
{
current = current.Next;
}
|
Ensure the translated C++ code behaves exactly like the original Factor snippet. | : list-each ( linked-list quot: ( data -- ) -- )
[ [ data>> ] dip call ]
[ [ next>> ] dip over [ list-each ] [ 2drop ] if ] 2bi ; inline recursive
SYMBOLS: A B C ;
A <linked-list>
[ C <linked-list> list-insert ] keep
[ B <linked-list> list-insert ] keep
[ . ] list-each
| #include <iostream>
#include <forward_list>
int main()
{
std::forward_list<int> list{1, 2, 3, 4, 5};
for (int e : list)
std::cout << e << std::endl;
}
|
Rewrite the snippet below in Java so it works the same as the original Factor code. | : list-each ( linked-list quot: ( data -- ) -- )
[ [ data>> ] dip call ]
[ [ next>> ] dip over [ list-each ] [ 2drop ] if ] 2bi ; inline recursive
SYMBOLS: A B C ;
A <linked-list>
[ C <linked-list> list-insert ] keep
[ B <linked-list> list-insert ] keep
[ . ] list-each
| LinkedList<Type> list = new LinkedList<Type>();
for(Type i: list){
System.out.println(i);
}
|
Produce a functionally identical Python code for the snippet given in Factor. | : list-each ( linked-list quot: ( data -- ) -- )
[ [ data>> ] dip call ]
[ [ next>> ] dip over [ list-each ] [ 2drop ] if ] 2bi ; inline recursive
SYMBOLS: A B C ;
A <linked-list>
[ C <linked-list> list-insert ] keep
[ B <linked-list> list-insert ] keep
[ . ] list-each
| for node in lst:
print node.value
|
Port the provided Factor code into VB while preserving the original functionality. | : list-each ( linked-list quot: ( data -- ) -- )
[ [ data>> ] dip call ]
[ [ next>> ] dip over [ list-each ] [ 2drop ] if ] 2bi ; inline recursive
SYMBOLS: A B C ;
A <linked-list>
[ C <linked-list> list-insert ] keep
[ B <linked-list> list-insert ] keep
[ . ] list-each
| Private Sub Iterate(ByVal list As LinkedList(Of Integer))
Dim node = list.First
Do Until node Is Nothing
node = node.Next
Loop
End Sub
|
Convert the following code from Factor to Go, ensuring the logic remains intact. | : list-each ( linked-list quot: ( data -- ) -- )
[ [ data>> ] dip call ]
[ [ next>> ] dip over [ list-each ] [ 2drop ] if ] 2bi ; inline recursive
SYMBOLS: A B C ;
A <linked-list>
[ C <linked-list> list-insert ] keep
[ B <linked-list> list-insert ] keep
[ . ] list-each
| start := &Ele{"tacos", nil}
end := start.Append("burritos")
end = end.Append("fajitas")
end = end.Append("enchilatas")
for iter := start; iter != nil; iter = iter.Next {
fmt.Println(iter)
}
|
Change the following Forth code into C without altering its purpose. | : last
begin dup @ while @ repeat ;
| struct link *first;
struct link *iter;
for(iter = first; iter != NULL; iter = iter->next) {
}
|
Produce a language-to-language conversion: from Forth to C#, same semantics. | : last
begin dup @ while @ repeat ;
| var current = [head of list to traverse]
while(current != null)
{
current = current.Next;
}
|
Translate this program into C++ but keep the logic exactly as in Forth. | : last
begin dup @ while @ repeat ;
| #include <iostream>
#include <forward_list>
int main()
{
std::forward_list<int> list{1, 2, 3, 4, 5};
for (int e : list)
std::cout << e << std::endl;
}
|
Change the programming language of this snippet from Forth to Java without modifying what it does. | : last
begin dup @ while @ repeat ;
| LinkedList<Type> list = new LinkedList<Type>();
for(Type i: list){
System.out.println(i);
}
|
Port the provided Forth code into VB while preserving the original functionality. | : last
begin dup @ while @ repeat ;
| Private Sub Iterate(ByVal list As LinkedList(Of Integer))
Dim node = list.First
Do Until node Is Nothing
node = node.Next
Loop
End Sub
|
Change the programming language of this snippet from Forth to Go without modifying what it does. | : last
begin dup @ while @ repeat ;
| start := &Ele{"tacos", nil}
end := start.Append("burritos")
end = end.Append("fajitas")
end = end.Append("enchilatas")
for iter := start; iter != nil; iter = iter.Next {
fmt.Println(iter)
}
|
Port the provided Fortran code into C# while preserving the original functionality. | subroutine traversal(list,proc)
type(node), target :: list
type(node), pointer :: current
interface
subroutine proc(node)
real, intent(in) :: node
end subroutine proc
end interface
current => list
do while ( associated(current) )
call proc(current%data)
current => current%next
end do
end subroutine traversal
| var current = [head of list to traverse]
while(current != null)
{
current = current.Next;
}
|
Convert this Fortran snippet to C++ and keep its semantics consistent. | subroutine traversal(list,proc)
type(node), target :: list
type(node), pointer :: current
interface
subroutine proc(node)
real, intent(in) :: node
end subroutine proc
end interface
current => list
do while ( associated(current) )
call proc(current%data)
current => current%next
end do
end subroutine traversal
| #include <iostream>
#include <forward_list>
int main()
{
std::forward_list<int> list{1, 2, 3, 4, 5};
for (int e : list)
std::cout << e << std::endl;
}
|
Write a version of this Fortran function in C with identical behavior. | subroutine traversal(list,proc)
type(node), target :: list
type(node), pointer :: current
interface
subroutine proc(node)
real, intent(in) :: node
end subroutine proc
end interface
current => list
do while ( associated(current) )
call proc(current%data)
current => current%next
end do
end subroutine traversal
| struct link *first;
struct link *iter;
for(iter = first; iter != NULL; iter = iter->next) {
}
|
Transform the following Fortran implementation into Java, maintaining the same output and logic. | subroutine traversal(list,proc)
type(node), target :: list
type(node), pointer :: current
interface
subroutine proc(node)
real, intent(in) :: node
end subroutine proc
end interface
current => list
do while ( associated(current) )
call proc(current%data)
current => current%next
end do
end subroutine traversal
| LinkedList<Type> list = new LinkedList<Type>();
for(Type i: list){
System.out.println(i);
}
|
Keep all operations the same but rewrite the snippet in Python. | subroutine traversal(list,proc)
type(node), target :: list
type(node), pointer :: current
interface
subroutine proc(node)
real, intent(in) :: node
end subroutine proc
end interface
current => list
do while ( associated(current) )
call proc(current%data)
current => current%next
end do
end subroutine traversal
| for node in lst:
print node.value
|
Port the provided Fortran code into VB while preserving the original functionality. | subroutine traversal(list,proc)
type(node), target :: list
type(node), pointer :: current
interface
subroutine proc(node)
real, intent(in) :: node
end subroutine proc
end interface
current => list
do while ( associated(current) )
call proc(current%data)
current => current%next
end do
end subroutine traversal
| Private Sub Iterate(ByVal list As LinkedList(Of Integer))
Dim node = list.First
Do Until node Is Nothing
node = node.Next
Loop
End Sub
|
Port the following code from Haskell to C with equivalent syntax and logic. | map (>5) [1..10]
map (++ "s") ["Apple", "Orange", "Mango", "Pear"]
foldr (+) 0 [1..10]
traverse :: [a] -> [a]
traverse list = map func list
where func a =
| struct link *first;
struct link *iter;
for(iter = first; iter != NULL; iter = iter->next) {
}
|
Maintain the same structure and functionality when rewriting this code in C#. | map (>5) [1..10]
map (++ "s") ["Apple", "Orange", "Mango", "Pear"]
foldr (+) 0 [1..10]
traverse :: [a] -> [a]
traverse list = map func list
where func a =
| var current = [head of list to traverse]
while(current != null)
{
current = current.Next;
}
|
Translate this program into C++ but keep the logic exactly as in Haskell. | map (>5) [1..10]
map (++ "s") ["Apple", "Orange", "Mango", "Pear"]
foldr (+) 0 [1..10]
traverse :: [a] -> [a]
traverse list = map func list
where func a =
| #include <iostream>
#include <forward_list>
int main()
{
std::forward_list<int> list{1, 2, 3, 4, 5};
for (int e : list)
std::cout << e << std::endl;
}
|
Change the following Haskell code into Java without altering its purpose. | map (>5) [1..10]
map (++ "s") ["Apple", "Orange", "Mango", "Pear"]
foldr (+) 0 [1..10]
traverse :: [a] -> [a]
traverse list = map func list
where func a =
| LinkedList<Type> list = new LinkedList<Type>();
for(Type i: list){
System.out.println(i);
}
|
Translate this program into Python but keep the logic exactly as in Haskell. | map (>5) [1..10]
map (++ "s") ["Apple", "Orange", "Mango", "Pear"]
foldr (+) 0 [1..10]
traverse :: [a] -> [a]
traverse list = map func list
where func a =
| for node in lst:
print node.value
|
Maintain the same structure and functionality when rewriting this code in VB. | map (>5) [1..10]
map (++ "s") ["Apple", "Orange", "Mango", "Pear"]
foldr (+) 0 [1..10]
traverse :: [a] -> [a]
traverse list = map func list
where func a =
| Private Sub Iterate(ByVal list As LinkedList(Of Integer))
Dim node = list.First
Do Until node Is Nothing
node = node.Next
Loop
End Sub
|
Preserve the algorithm and functionality while converting the code from Haskell to Go. | map (>5) [1..10]
map (++ "s") ["Apple", "Orange", "Mango", "Pear"]
foldr (+) 0 [1..10]
traverse :: [a] -> [a]
traverse list = map func list
where func a =
| start := &Ele{"tacos", nil}
end := start.Append("burritos")
end = end.Append("fajitas")
end = end.Append("enchilatas")
for iter := start; iter != nil; iter = iter.Next {
fmt.Println(iter)
}
|
Convert this Icon block to C, preserving its control flow and logic. | procedure main ()
ns := Node(1, Node(2, Node (3)))
until /ns do {
write (ns.value)
ns := ns.successor
}
end
| struct link *first;
struct link *iter;
for(iter = first; iter != NULL; iter = iter->next) {
}
|
Write the same algorithm in C# as shown in this Icon implementation. | procedure main ()
ns := Node(1, Node(2, Node (3)))
until /ns do {
write (ns.value)
ns := ns.successor
}
end
| var current = [head of list to traverse]
while(current != null)
{
current = current.Next;
}
|
Rewrite this program in C++ while keeping its functionality equivalent to the Icon version. | procedure main ()
ns := Node(1, Node(2, Node (3)))
until /ns do {
write (ns.value)
ns := ns.successor
}
end
| #include <iostream>
#include <forward_list>
int main()
{
std::forward_list<int> list{1, 2, 3, 4, 5};
for (int e : list)
std::cout << e << std::endl;
}
|
Translate this program into Java but keep the logic exactly as in Icon. | procedure main ()
ns := Node(1, Node(2, Node (3)))
until /ns do {
write (ns.value)
ns := ns.successor
}
end
| LinkedList<Type> list = new LinkedList<Type>();
for(Type i: list){
System.out.println(i);
}
|
Ensure the translated Python code behaves exactly like the original Icon snippet. | procedure main ()
ns := Node(1, Node(2, Node (3)))
until /ns do {
write (ns.value)
ns := ns.successor
}
end
| for node in lst:
print node.value
|
Port the following code from Icon to VB with equivalent syntax and logic. | procedure main ()
ns := Node(1, Node(2, Node (3)))
until /ns do {
write (ns.value)
ns := ns.successor
}
end
| Private Sub Iterate(ByVal list As LinkedList(Of Integer))
Dim node = list.First
Do Until node Is Nothing
node = node.Next
Loop
End Sub
|
Rewrite the snippet below in Go so it works the same as the original Icon code. | procedure main ()
ns := Node(1, Node(2, Node (3)))
until /ns do {
write (ns.value)
ns := ns.successor
}
end
| start := &Ele{"tacos", nil}
end := start.Append("burritos")
end = end.Append("fajitas")
end = end.Append("enchilatas")
for iter := start; iter != nil; iter = iter.Next {
fmt.Println(iter)
}
|
Rewrite the snippet below in C so it works the same as the original J code. | foo"0 {:"1 list
| struct link *first;
struct link *iter;
for(iter = first; iter != NULL; iter = iter->next) {
}
|
Rewrite the snippet below in C# so it works the same as the original J code. | foo"0 {:"1 list
| var current = [head of list to traverse]
while(current != null)
{
current = current.Next;
}
|
Generate a C++ translation of this J snippet without changing its computational steps. | foo"0 {:"1 list
| #include <iostream>
#include <forward_list>
int main()
{
std::forward_list<int> list{1, 2, 3, 4, 5};
for (int e : list)
std::cout << e << std::endl;
}
|
Produce a functionally identical Java code for the snippet given in J. | foo"0 {:"1 list
| LinkedList<Type> list = new LinkedList<Type>();
for(Type i: list){
System.out.println(i);
}
|
Rewrite this program in VB while keeping its functionality equivalent to the J version. | foo"0 {:"1 list
| Private Sub Iterate(ByVal list As LinkedList(Of Integer))
Dim node = list.First
Do Until node Is Nothing
node = node.Next
Loop
End Sub
|
Produce a language-to-language conversion: from J to Go, same semantics. | foo"0 {:"1 list
| start := &Ele{"tacos", nil}
end := start.Append("burritos")
end = end.Append("fajitas")
end = end.Append("enchilatas")
for iter := start; iter != nil; iter = iter.Next {
fmt.Println(iter)
}
|
Write a version of this Julia function in C with identical behavior. | Base.start(ll::LinkedList) = ll.head
Base.done(ll::LinkedList{T}, st::AbstractNode{T}) where T = st isa EmptyNode
Base.next(ll::LinkedList{T}, st::AbstractNode{T}) where T = st.data, st.next
lst = LinkedList{Int}()
push!(lst, 1)
push!(lst, 2)
push!(lst, 3)
for n in lst
print(n, " ")
end
| struct link *first;
struct link *iter;
for(iter = first; iter != NULL; iter = iter->next) {
}
|
Change the programming language of this snippet from Julia to C# without modifying what it does. | Base.start(ll::LinkedList) = ll.head
Base.done(ll::LinkedList{T}, st::AbstractNode{T}) where T = st isa EmptyNode
Base.next(ll::LinkedList{T}, st::AbstractNode{T}) where T = st.data, st.next
lst = LinkedList{Int}()
push!(lst, 1)
push!(lst, 2)
push!(lst, 3)
for n in lst
print(n, " ")
end
| var current = [head of list to traverse]
while(current != null)
{
current = current.Next;
}
|
Produce a functionally identical C++ code for the snippet given in Julia. | Base.start(ll::LinkedList) = ll.head
Base.done(ll::LinkedList{T}, st::AbstractNode{T}) where T = st isa EmptyNode
Base.next(ll::LinkedList{T}, st::AbstractNode{T}) where T = st.data, st.next
lst = LinkedList{Int}()
push!(lst, 1)
push!(lst, 2)
push!(lst, 3)
for n in lst
print(n, " ")
end
| #include <iostream>
#include <forward_list>
int main()
{
std::forward_list<int> list{1, 2, 3, 4, 5};
for (int e : list)
std::cout << e << std::endl;
}
|
Produce a language-to-language conversion: from Julia to Java, same semantics. | Base.start(ll::LinkedList) = ll.head
Base.done(ll::LinkedList{T}, st::AbstractNode{T}) where T = st isa EmptyNode
Base.next(ll::LinkedList{T}, st::AbstractNode{T}) where T = st.data, st.next
lst = LinkedList{Int}()
push!(lst, 1)
push!(lst, 2)
push!(lst, 3)
for n in lst
print(n, " ")
end
| LinkedList<Type> list = new LinkedList<Type>();
for(Type i: list){
System.out.println(i);
}
|
Maintain the same structure and functionality when rewriting this code in Python. | Base.start(ll::LinkedList) = ll.head
Base.done(ll::LinkedList{T}, st::AbstractNode{T}) where T = st isa EmptyNode
Base.next(ll::LinkedList{T}, st::AbstractNode{T}) where T = st.data, st.next
lst = LinkedList{Int}()
push!(lst, 1)
push!(lst, 2)
push!(lst, 3)
for n in lst
print(n, " ")
end
| for node in lst:
print node.value
|
Can you help me rewrite this code in VB instead of Julia, keeping it the same logically? | Base.start(ll::LinkedList) = ll.head
Base.done(ll::LinkedList{T}, st::AbstractNode{T}) where T = st isa EmptyNode
Base.next(ll::LinkedList{T}, st::AbstractNode{T}) where T = st.data, st.next
lst = LinkedList{Int}()
push!(lst, 1)
push!(lst, 2)
push!(lst, 3)
for n in lst
print(n, " ")
end
| Private Sub Iterate(ByVal list As LinkedList(Of Integer))
Dim node = list.First
Do Until node Is Nothing
node = node.Next
Loop
End Sub
|
Transform the following Julia implementation into Go, maintaining the same output and logic. | Base.start(ll::LinkedList) = ll.head
Base.done(ll::LinkedList{T}, st::AbstractNode{T}) where T = st isa EmptyNode
Base.next(ll::LinkedList{T}, st::AbstractNode{T}) where T = st.data, st.next
lst = LinkedList{Int}()
push!(lst, 1)
push!(lst, 2)
push!(lst, 3)
for n in lst
print(n, " ")
end
| start := &Ele{"tacos", nil}
end := start.Append("burritos")
end = end.Append("fajitas")
end = end.Append("enchilatas")
for iter := start; iter != nil; iter = iter.Next {
fmt.Println(iter)
}
|
Can you help me rewrite this code in C instead of Mathematica, keeping it the same logically? | Print /@ {"rosettacode", "kitten", "sitting", "rosettacode", "raisethysword"}
| struct link *first;
struct link *iter;
for(iter = first; iter != NULL; iter = iter->next) {
}
|
Write the same code in C# as shown below in Mathematica. | Print /@ {"rosettacode", "kitten", "sitting", "rosettacode", "raisethysword"}
| var current = [head of list to traverse]
while(current != null)
{
current = current.Next;
}
|
Convert the following code from Mathematica to C++, ensuring the logic remains intact. | Print /@ {"rosettacode", "kitten", "sitting", "rosettacode", "raisethysword"}
| #include <iostream>
#include <forward_list>
int main()
{
std::forward_list<int> list{1, 2, 3, 4, 5};
for (int e : list)
std::cout << e << std::endl;
}
|
Change the following Mathematica code into Java without altering its purpose. | Print /@ {"rosettacode", "kitten", "sitting", "rosettacode", "raisethysword"}
| LinkedList<Type> list = new LinkedList<Type>();
for(Type i: list){
System.out.println(i);
}
|
Convert this Mathematica block to Python, preserving its control flow and logic. | Print /@ {"rosettacode", "kitten", "sitting", "rosettacode", "raisethysword"}
| for node in lst:
print node.value
|
Convert this Mathematica block to VB, preserving its control flow and logic. | Print /@ {"rosettacode", "kitten", "sitting", "rosettacode", "raisethysword"}
| Private Sub Iterate(ByVal list As LinkedList(Of Integer))
Dim node = list.First
Do Until node Is Nothing
node = node.Next
Loop
End Sub
|
Write the same code in Go as shown below in Mathematica. | Print /@ {"rosettacode", "kitten", "sitting", "rosettacode", "raisethysword"}
| start := &Ele{"tacos", nil}
end := start.Append("burritos")
end = end.Append("fajitas")
end = end.Append("enchilatas")
for iter := start; iter != nil; iter = iter.Next {
fmt.Println(iter)
}
|
Please provide an equivalent version of this MATLAB code in C. | list = 1:10;
for k=1:length(list)
printf('
end;
| struct link *first;
struct link *iter;
for(iter = first; iter != NULL; iter = iter->next) {
}
|
Write the same algorithm in C# as shown in this MATLAB implementation. | list = 1:10;
for k=1:length(list)
printf('
end;
| var current = [head of list to traverse]
while(current != null)
{
current = current.Next;
}
|
Keep all operations the same but rewrite the snippet in C++. | list = 1:10;
for k=1:length(list)
printf('
end;
| #include <iostream>
#include <forward_list>
int main()
{
std::forward_list<int> list{1, 2, 3, 4, 5};
for (int e : list)
std::cout << e << std::endl;
}
|
Convert the following code from MATLAB to Java, ensuring the logic remains intact. | list = 1:10;
for k=1:length(list)
printf('
end;
| LinkedList<Type> list = new LinkedList<Type>();
for(Type i: list){
System.out.println(i);
}
|
Please provide an equivalent version of this MATLAB code in VB. | list = 1:10;
for k=1:length(list)
printf('
end;
| Private Sub Iterate(ByVal list As LinkedList(Of Integer))
Dim node = list.First
Do Until node Is Nothing
node = node.Next
Loop
End Sub
|
Ensure the translated Go code behaves exactly like the original MATLAB snippet. | list = 1:10;
for k=1:length(list)
printf('
end;
| start := &Ele{"tacos", nil}
end := start.Append("burritos")
end = end.Append("fajitas")
end = end.Append("enchilatas")
for iter := start; iter != nil; iter = iter.Next {
fmt.Println(iter)
}
|
Maintain the same structure and functionality when rewriting this code in C. | type Node[T] = ref object
next: Node[T]
data: T
proc newNode[T](data: T): Node[T] =
Node[T](data: data)
var a = newNode 12
var b = newNode 13
var c = newNode 14
proc insertAppend(a, n: var Node) =
n.next = a.next
a.next = n
a.insertAppend(b)
b.insertAppend(c)
iterator items(a: Node) =
var x = a
while not x.isNil:
yield x
x = x.next
for item in a:
echo item.data
| struct link *first;
struct link *iter;
for(iter = first; iter != NULL; iter = iter->next) {
}
|
Maintain the same structure and functionality when rewriting this code in C#. | type Node[T] = ref object
next: Node[T]
data: T
proc newNode[T](data: T): Node[T] =
Node[T](data: data)
var a = newNode 12
var b = newNode 13
var c = newNode 14
proc insertAppend(a, n: var Node) =
n.next = a.next
a.next = n
a.insertAppend(b)
b.insertAppend(c)
iterator items(a: Node) =
var x = a
while not x.isNil:
yield x
x = x.next
for item in a:
echo item.data
| var current = [head of list to traverse]
while(current != null)
{
current = current.Next;
}
|
Ensure the translated C++ code behaves exactly like the original Nim snippet. | type Node[T] = ref object
next: Node[T]
data: T
proc newNode[T](data: T): Node[T] =
Node[T](data: data)
var a = newNode 12
var b = newNode 13
var c = newNode 14
proc insertAppend(a, n: var Node) =
n.next = a.next
a.next = n
a.insertAppend(b)
b.insertAppend(c)
iterator items(a: Node) =
var x = a
while not x.isNil:
yield x
x = x.next
for item in a:
echo item.data
| #include <iostream>
#include <forward_list>
int main()
{
std::forward_list<int> list{1, 2, 3, 4, 5};
for (int e : list)
std::cout << e << std::endl;
}
|
Write the same algorithm in Java as shown in this Nim implementation. | type Node[T] = ref object
next: Node[T]
data: T
proc newNode[T](data: T): Node[T] =
Node[T](data: data)
var a = newNode 12
var b = newNode 13
var c = newNode 14
proc insertAppend(a, n: var Node) =
n.next = a.next
a.next = n
a.insertAppend(b)
b.insertAppend(c)
iterator items(a: Node) =
var x = a
while not x.isNil:
yield x
x = x.next
for item in a:
echo item.data
| LinkedList<Type> list = new LinkedList<Type>();
for(Type i: list){
System.out.println(i);
}
|
Generate an equivalent Python version of this Nim code. | type Node[T] = ref object
next: Node[T]
data: T
proc newNode[T](data: T): Node[T] =
Node[T](data: data)
var a = newNode 12
var b = newNode 13
var c = newNode 14
proc insertAppend(a, n: var Node) =
n.next = a.next
a.next = n
a.insertAppend(b)
b.insertAppend(c)
iterator items(a: Node) =
var x = a
while not x.isNil:
yield x
x = x.next
for item in a:
echo item.data
| for node in lst:
print node.value
|
Write the same code in VB as shown below in Nim. | type Node[T] = ref object
next: Node[T]
data: T
proc newNode[T](data: T): Node[T] =
Node[T](data: data)
var a = newNode 12
var b = newNode 13
var c = newNode 14
proc insertAppend(a, n: var Node) =
n.next = a.next
a.next = n
a.insertAppend(b)
b.insertAppend(c)
iterator items(a: Node) =
var x = a
while not x.isNil:
yield x
x = x.next
for item in a:
echo item.data
| Private Sub Iterate(ByVal list As LinkedList(Of Integer))
Dim node = list.First
Do Until node Is Nothing
node = node.Next
Loop
End Sub
|
Write the same code in Go as shown below in Nim. | type Node[T] = ref object
next: Node[T]
data: T
proc newNode[T](data: T): Node[T] =
Node[T](data: data)
var a = newNode 12
var b = newNode 13
var c = newNode 14
proc insertAppend(a, n: var Node) =
n.next = a.next
a.next = n
a.insertAppend(b)
b.insertAppend(c)
iterator items(a: Node) =
var x = a
while not x.isNil:
yield x
x = x.next
for item in a:
echo item.data
| start := &Ele{"tacos", nil}
end := start.Append("burritos")
end = end.Append("fajitas")
end = end.Append("enchilatas")
for iter := start; iter != nil; iter = iter.Next {
fmt.Println(iter)
}
|
Translate the given OCaml code snippet into C without altering its behavior. | # let li = ["big"; "fjords"; "vex"; "quick"; "waltz"; "nymph"] in
List.iter print_endline li ;;
big
fjords
vex
quick
waltz
nymph
- : unit = ()
| struct link *first;
struct link *iter;
for(iter = first; iter != NULL; iter = iter->next) {
}
|
Please provide an equivalent version of this OCaml code in C#. | # let li = ["big"; "fjords"; "vex"; "quick"; "waltz"; "nymph"] in
List.iter print_endline li ;;
big
fjords
vex
quick
waltz
nymph
- : unit = ()
| var current = [head of list to traverse]
while(current != null)
{
current = current.Next;
}
|
Generate an equivalent C++ version of this OCaml code. | # let li = ["big"; "fjords"; "vex"; "quick"; "waltz"; "nymph"] in
List.iter print_endline li ;;
big
fjords
vex
quick
waltz
nymph
- : unit = ()
| #include <iostream>
#include <forward_list>
int main()
{
std::forward_list<int> list{1, 2, 3, 4, 5};
for (int e : list)
std::cout << e << std::endl;
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.