Instruction stringlengths 45 106 | input_code stringlengths 1 13.7k | output_code stringlengths 1 13.7k |
|---|---|---|
Convert this Erlang snippet to Java and keep its semantics consistent. | -module( globally_replace_text ).
-export( [in_files/3, main/1] ).
in_files( Old, New, Files ) when is_list(Old) ->
in_files( binary:list_to_bin(Old), binary:list_to_bin(New), Files );
in_files( Old, New, Files ) -> [replace_in_file(Old, New, X, file:read_file(X)) || X <- Files].
main( [Old, New | Files] ) -... | import java.io.*;
import java.nio.file.*;
public class GloballyReplaceText {
public static void main(String[] args) throws IOException {
for (String fn : new String[]{"test1.txt", "test2.txt"}) {
String s = new String(Files.readAllBytes(Paths.get(fn)));
s = s.replace("Goodbye Lond... |
Write a version of this Erlang function in Java with identical behavior. | -module( globally_replace_text ).
-export( [in_files/3, main/1] ).
in_files( Old, New, Files ) when is_list(Old) ->
in_files( binary:list_to_bin(Old), binary:list_to_bin(New), Files );
in_files( Old, New, Files ) -> [replace_in_file(Old, New, X, file:read_file(X)) || X <- Files].
main( [Old, New | Files] ) -... | import java.io.*;
import java.nio.file.*;
public class GloballyReplaceText {
public static void main(String[] args) throws IOException {
for (String fn : new String[]{"test1.txt", "test2.txt"}) {
String s = new String(Files.readAllBytes(Paths.get(fn)));
s = s.replace("Goodbye Lond... |
Produce a language-to-language conversion: from Erlang to Python, same semantics. | -module( globally_replace_text ).
-export( [in_files/3, main/1] ).
in_files( Old, New, Files ) when is_list(Old) ->
in_files( binary:list_to_bin(Old), binary:list_to_bin(New), Files );
in_files( Old, New, Files ) -> [replace_in_file(Old, New, X, file:read_file(X)) || X <- Files].
main( [Old, New | Files] ) -... | import fileinput
for line in fileinput.input(inplace=True):
print(line.replace('Goodbye London!', 'Hello New York!'), end='')
|
Convert the following code from Erlang to Python, ensuring the logic remains intact. | -module( globally_replace_text ).
-export( [in_files/3, main/1] ).
in_files( Old, New, Files ) when is_list(Old) ->
in_files( binary:list_to_bin(Old), binary:list_to_bin(New), Files );
in_files( Old, New, Files ) -> [replace_in_file(Old, New, X, file:read_file(X)) || X <- Files].
main( [Old, New | Files] ) -... | import fileinput
for line in fileinput.input(inplace=True):
print(line.replace('Goodbye London!', 'Hello New York!'), end='')
|
Translate the given Erlang code snippet into Go without altering its behavior. | -module( globally_replace_text ).
-export( [in_files/3, main/1] ).
in_files( Old, New, Files ) when is_list(Old) ->
in_files( binary:list_to_bin(Old), binary:list_to_bin(New), Files );
in_files( Old, New, Files ) -> [replace_in_file(Old, New, X, file:read_file(X)) || X <- Files].
main( [Old, New | Files] ) -... | package main
import (
"bytes"
"io/ioutil"
"log"
"os"
)
func main() {
gRepNFiles("Goodbye London!", "Hello New York!", []string{
"a.txt",
"b.txt",
"c.txt",
})
}
func gRepNFiles(olds, news string, files []string) {
oldb := []byte(olds)
newb := []byte(news)
fo... |
Convert this Erlang snippet to Go and keep its semantics consistent. | -module( globally_replace_text ).
-export( [in_files/3, main/1] ).
in_files( Old, New, Files ) when is_list(Old) ->
in_files( binary:list_to_bin(Old), binary:list_to_bin(New), Files );
in_files( Old, New, Files ) -> [replace_in_file(Old, New, X, file:read_file(X)) || X <- Files].
main( [Old, New | Files] ) -... | package main
import (
"bytes"
"io/ioutil"
"log"
"os"
)
func main() {
gRepNFiles("Goodbye London!", "Hello New York!", []string{
"a.txt",
"b.txt",
"c.txt",
})
}
func gRepNFiles(olds, news string, files []string) {
oldb := []byte(olds)
newb := []byte(news)
fo... |
Port the following code from F# to C with equivalent syntax and logic. | open System.IO
[<EntryPoint>]
let main args =
let textFrom = "Goodbye London!"
let textTo = "Hello New York!"
for name in args do
let content = File.ReadAllText(name)
let newContent = content.Replace(textFrom, textTo)
if content <> newContent then
File.WriteAllText(name,... | #include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <sys/types.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <unistd.h>
#include <err.h>
#include <string.h>
char * find_match(const char *buf, const char * buf_end, const char *pat, size_t len)
{
ptrdiff_t i;
char *start = bu... |
Ensure the translated C code behaves exactly like the original F# snippet. | open System.IO
[<EntryPoint>]
let main args =
let textFrom = "Goodbye London!"
let textTo = "Hello New York!"
for name in args do
let content = File.ReadAllText(name)
let newContent = content.Replace(textFrom, textTo)
if content <> newContent then
File.WriteAllText(name,... | #include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <sys/types.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <unistd.h>
#include <err.h>
#include <string.h>
char * find_match(const char *buf, const char * buf_end, const char *pat, size_t len)
{
ptrdiff_t i;
char *start = bu... |
Generate an equivalent C# version of this F# code. | open System.IO
[<EntryPoint>]
let main args =
let textFrom = "Goodbye London!"
let textTo = "Hello New York!"
for name in args do
let content = File.ReadAllText(name)
let newContent = content.Replace(textFrom, textTo)
if content <> newContent then
File.WriteAllText(name,... | using System.Collections.Generic;
using System.IO;
class Program {
static void Main() {
var files = new List<string> {
"test1.txt",
"test2.txt"
};
foreach (string file in files) {
File.WriteAllText(file, File.ReadAllText(file).Replace("Goodbye London!", "... |
Preserve the algorithm and functionality while converting the code from F# to C#. | open System.IO
[<EntryPoint>]
let main args =
let textFrom = "Goodbye London!"
let textTo = "Hello New York!"
for name in args do
let content = File.ReadAllText(name)
let newContent = content.Replace(textFrom, textTo)
if content <> newContent then
File.WriteAllText(name,... | using System.Collections.Generic;
using System.IO;
class Program {
static void Main() {
var files = new List<string> {
"test1.txt",
"test2.txt"
};
foreach (string file in files) {
File.WriteAllText(file, File.ReadAllText(file).Replace("Goodbye London!", "... |
Ensure the translated C++ code behaves exactly like the original F# snippet. | open System.IO
[<EntryPoint>]
let main args =
let textFrom = "Goodbye London!"
let textTo = "Hello New York!"
for name in args do
let content = File.ReadAllText(name)
let newContent = content.Replace(textFrom, textTo)
if content <> newContent then
File.WriteAllText(name,... | #include <fstream>
#include <iterator>
#include <boost/regex.hpp>
#include <string>
#include <iostream>
int main( int argc , char *argv[ ] ) {
boost::regex to_be_replaced( "Goodbye London\\s*!" ) ;
std::string replacement( "Hello New York!" ) ;
for ( int i = 1 ; i < argc ; i++ ) {
std::ifstream infile (... |
Generate a C++ translation of this F# snippet without changing its computational steps. | open System.IO
[<EntryPoint>]
let main args =
let textFrom = "Goodbye London!"
let textTo = "Hello New York!"
for name in args do
let content = File.ReadAllText(name)
let newContent = content.Replace(textFrom, textTo)
if content <> newContent then
File.WriteAllText(name,... | #include <fstream>
#include <iterator>
#include <boost/regex.hpp>
#include <string>
#include <iostream>
int main( int argc , char *argv[ ] ) {
boost::regex to_be_replaced( "Goodbye London\\s*!" ) ;
std::string replacement( "Hello New York!" ) ;
for ( int i = 1 ; i < argc ; i++ ) {
std::ifstream infile (... |
Ensure the translated Java code behaves exactly like the original F# snippet. | open System.IO
[<EntryPoint>]
let main args =
let textFrom = "Goodbye London!"
let textTo = "Hello New York!"
for name in args do
let content = File.ReadAllText(name)
let newContent = content.Replace(textFrom, textTo)
if content <> newContent then
File.WriteAllText(name,... | import java.io.*;
import java.nio.file.*;
public class GloballyReplaceText {
public static void main(String[] args) throws IOException {
for (String fn : new String[]{"test1.txt", "test2.txt"}) {
String s = new String(Files.readAllBytes(Paths.get(fn)));
s = s.replace("Goodbye Lond... |
Keep all operations the same but rewrite the snippet in Java. | open System.IO
[<EntryPoint>]
let main args =
let textFrom = "Goodbye London!"
let textTo = "Hello New York!"
for name in args do
let content = File.ReadAllText(name)
let newContent = content.Replace(textFrom, textTo)
if content <> newContent then
File.WriteAllText(name,... | import java.io.*;
import java.nio.file.*;
public class GloballyReplaceText {
public static void main(String[] args) throws IOException {
for (String fn : new String[]{"test1.txt", "test2.txt"}) {
String s = new String(Files.readAllBytes(Paths.get(fn)));
s = s.replace("Goodbye Lond... |
Please provide an equivalent version of this F# code in Python. | open System.IO
[<EntryPoint>]
let main args =
let textFrom = "Goodbye London!"
let textTo = "Hello New York!"
for name in args do
let content = File.ReadAllText(name)
let newContent = content.Replace(textFrom, textTo)
if content <> newContent then
File.WriteAllText(name,... | import fileinput
for line in fileinput.input(inplace=True):
print(line.replace('Goodbye London!', 'Hello New York!'), end='')
|
Write a version of this F# function in Python with identical behavior. | open System.IO
[<EntryPoint>]
let main args =
let textFrom = "Goodbye London!"
let textTo = "Hello New York!"
for name in args do
let content = File.ReadAllText(name)
let newContent = content.Replace(textFrom, textTo)
if content <> newContent then
File.WriteAllText(name,... | import fileinput
for line in fileinput.input(inplace=True):
print(line.replace('Goodbye London!', 'Hello New York!'), end='')
|
Translate the given F# code snippet into Go without altering its behavior. | open System.IO
[<EntryPoint>]
let main args =
let textFrom = "Goodbye London!"
let textTo = "Hello New York!"
for name in args do
let content = File.ReadAllText(name)
let newContent = content.Replace(textFrom, textTo)
if content <> newContent then
File.WriteAllText(name,... | package main
import (
"bytes"
"io/ioutil"
"log"
"os"
)
func main() {
gRepNFiles("Goodbye London!", "Hello New York!", []string{
"a.txt",
"b.txt",
"c.txt",
})
}
func gRepNFiles(olds, news string, files []string) {
oldb := []byte(olds)
newb := []byte(news)
fo... |
Maintain the same structure and functionality when rewriting this code in Go. | open System.IO
[<EntryPoint>]
let main args =
let textFrom = "Goodbye London!"
let textTo = "Hello New York!"
for name in args do
let content = File.ReadAllText(name)
let newContent = content.Replace(textFrom, textTo)
if content <> newContent then
File.WriteAllText(name,... | package main
import (
"bytes"
"io/ioutil"
"log"
"os"
)
func main() {
gRepNFiles("Goodbye London!", "Hello New York!", []string{
"a.txt",
"b.txt",
"c.txt",
})
}
func gRepNFiles(olds, news string, files []string) {
oldb := []byte(olds)
newb := []byte(news)
fo... |
Convert the following code from Factor to C, ensuring the logic remains intact. | USING: fry io.encodings.utf8 io.files kernel qw sequences
splitting ;
: global-replace ( files old new -- )
'[
[ utf8 file-contents _ _ replace ]
[ utf8 set-file-contents ] bi
] each ;
qw{ a.txt b.txt c.txt }
"Goodbye London
| #include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <sys/types.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <unistd.h>
#include <err.h>
#include <string.h>
char * find_match(const char *buf, const char * buf_end, const char *pat, size_t len)
{
ptrdiff_t i;
char *start = bu... |
Rewrite this program in C while keeping its functionality equivalent to the Factor version. | USING: fry io.encodings.utf8 io.files kernel qw sequences
splitting ;
: global-replace ( files old new -- )
'[
[ utf8 file-contents _ _ replace ]
[ utf8 set-file-contents ] bi
] each ;
qw{ a.txt b.txt c.txt }
"Goodbye London
| #include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <sys/types.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <unistd.h>
#include <err.h>
#include <string.h>
char * find_match(const char *buf, const char * buf_end, const char *pat, size_t len)
{
ptrdiff_t i;
char *start = bu... |
Change the following Factor code into C# without altering its purpose. | USING: fry io.encodings.utf8 io.files kernel qw sequences
splitting ;
: global-replace ( files old new -- )
'[
[ utf8 file-contents _ _ replace ]
[ utf8 set-file-contents ] bi
] each ;
qw{ a.txt b.txt c.txt }
"Goodbye London
| using System.Collections.Generic;
using System.IO;
class Program {
static void Main() {
var files = new List<string> {
"test1.txt",
"test2.txt"
};
foreach (string file in files) {
File.WriteAllText(file, File.ReadAllText(file).Replace("Goodbye London!", "... |
Generate an equivalent C# version of this Factor code. | USING: fry io.encodings.utf8 io.files kernel qw sequences
splitting ;
: global-replace ( files old new -- )
'[
[ utf8 file-contents _ _ replace ]
[ utf8 set-file-contents ] bi
] each ;
qw{ a.txt b.txt c.txt }
"Goodbye London
| using System.Collections.Generic;
using System.IO;
class Program {
static void Main() {
var files = new List<string> {
"test1.txt",
"test2.txt"
};
foreach (string file in files) {
File.WriteAllText(file, File.ReadAllText(file).Replace("Goodbye London!", "... |
Write the same algorithm in C++ as shown in this Factor implementation. | USING: fry io.encodings.utf8 io.files kernel qw sequences
splitting ;
: global-replace ( files old new -- )
'[
[ utf8 file-contents _ _ replace ]
[ utf8 set-file-contents ] bi
] each ;
qw{ a.txt b.txt c.txt }
"Goodbye London
| #include <fstream>
#include <iterator>
#include <boost/regex.hpp>
#include <string>
#include <iostream>
int main( int argc , char *argv[ ] ) {
boost::regex to_be_replaced( "Goodbye London\\s*!" ) ;
std::string replacement( "Hello New York!" ) ;
for ( int i = 1 ; i < argc ; i++ ) {
std::ifstream infile (... |
Port the provided Factor code into C++ while preserving the original functionality. | USING: fry io.encodings.utf8 io.files kernel qw sequences
splitting ;
: global-replace ( files old new -- )
'[
[ utf8 file-contents _ _ replace ]
[ utf8 set-file-contents ] bi
] each ;
qw{ a.txt b.txt c.txt }
"Goodbye London
| #include <fstream>
#include <iterator>
#include <boost/regex.hpp>
#include <string>
#include <iostream>
int main( int argc , char *argv[ ] ) {
boost::regex to_be_replaced( "Goodbye London\\s*!" ) ;
std::string replacement( "Hello New York!" ) ;
for ( int i = 1 ; i < argc ; i++ ) {
std::ifstream infile (... |
Can you help me rewrite this code in Java instead of Factor, keeping it the same logically? | USING: fry io.encodings.utf8 io.files kernel qw sequences
splitting ;
: global-replace ( files old new -- )
'[
[ utf8 file-contents _ _ replace ]
[ utf8 set-file-contents ] bi
] each ;
qw{ a.txt b.txt c.txt }
"Goodbye London
| import java.io.*;
import java.nio.file.*;
public class GloballyReplaceText {
public static void main(String[] args) throws IOException {
for (String fn : new String[]{"test1.txt", "test2.txt"}) {
String s = new String(Files.readAllBytes(Paths.get(fn)));
s = s.replace("Goodbye Lond... |
Change the programming language of this snippet from Factor to Java without modifying what it does. | USING: fry io.encodings.utf8 io.files kernel qw sequences
splitting ;
: global-replace ( files old new -- )
'[
[ utf8 file-contents _ _ replace ]
[ utf8 set-file-contents ] bi
] each ;
qw{ a.txt b.txt c.txt }
"Goodbye London
| import java.io.*;
import java.nio.file.*;
public class GloballyReplaceText {
public static void main(String[] args) throws IOException {
for (String fn : new String[]{"test1.txt", "test2.txt"}) {
String s = new String(Files.readAllBytes(Paths.get(fn)));
s = s.replace("Goodbye Lond... |
Generate a Python translation of this Factor snippet without changing its computational steps. | USING: fry io.encodings.utf8 io.files kernel qw sequences
splitting ;
: global-replace ( files old new -- )
'[
[ utf8 file-contents _ _ replace ]
[ utf8 set-file-contents ] bi
] each ;
qw{ a.txt b.txt c.txt }
"Goodbye London
| import fileinput
for line in fileinput.input(inplace=True):
print(line.replace('Goodbye London!', 'Hello New York!'), end='')
|
Generate an equivalent Python version of this Factor code. | USING: fry io.encodings.utf8 io.files kernel qw sequences
splitting ;
: global-replace ( files old new -- )
'[
[ utf8 file-contents _ _ replace ]
[ utf8 set-file-contents ] bi
] each ;
qw{ a.txt b.txt c.txt }
"Goodbye London
| import fileinput
for line in fileinput.input(inplace=True):
print(line.replace('Goodbye London!', 'Hello New York!'), end='')
|
Translate this program into Go but keep the logic exactly as in Factor. | USING: fry io.encodings.utf8 io.files kernel qw sequences
splitting ;
: global-replace ( files old new -- )
'[
[ utf8 file-contents _ _ replace ]
[ utf8 set-file-contents ] bi
] each ;
qw{ a.txt b.txt c.txt }
"Goodbye London
| package main
import (
"bytes"
"io/ioutil"
"log"
"os"
)
func main() {
gRepNFiles("Goodbye London!", "Hello New York!", []string{
"a.txt",
"b.txt",
"c.txt",
})
}
func gRepNFiles(olds, news string, files []string) {
oldb := []byte(olds)
newb := []byte(news)
fo... |
Transform the following Factor implementation into Go, maintaining the same output and logic. | USING: fry io.encodings.utf8 io.files kernel qw sequences
splitting ;
: global-replace ( files old new -- )
'[
[ utf8 file-contents _ _ replace ]
[ utf8 set-file-contents ] bi
] each ;
qw{ a.txt b.txt c.txt }
"Goodbye London
| package main
import (
"bytes"
"io/ioutil"
"log"
"os"
)
func main() {
gRepNFiles("Goodbye London!", "Hello New York!", []string{
"a.txt",
"b.txt",
"c.txt",
})
}
func gRepNFiles(olds, news string, files []string) {
oldb := []byte(olds)
newb := []byte(news)
fo... |
Generate a C# translation of this Fortran snippet without changing its computational steps. | SUBROUTINE FILEHACK(FNAME,THIS,THAT)
CHARACTER*(*) FNAME
CHARACTER*(*) THIS
CHARACTER*(*) THAT
INTEGER F,T
PARAMETER (F=66,T=67)
INTEGER L
CHARACTER*6666 ALINE
LOGICAL AHIT
INQUIRE(FILE = FNAME, EXIST = AHIT)
IF (.NOT.AHIT) RETUR... | using System.Collections.Generic;
using System.IO;
class Program {
static void Main() {
var files = new List<string> {
"test1.txt",
"test2.txt"
};
foreach (string file in files) {
File.WriteAllText(file, File.ReadAllText(file).Replace("Goodbye London!", "... |
Write the same algorithm in C# as shown in this Fortran implementation. | SUBROUTINE FILEHACK(FNAME,THIS,THAT)
CHARACTER*(*) FNAME
CHARACTER*(*) THIS
CHARACTER*(*) THAT
INTEGER F,T
PARAMETER (F=66,T=67)
INTEGER L
CHARACTER*6666 ALINE
LOGICAL AHIT
INQUIRE(FILE = FNAME, EXIST = AHIT)
IF (.NOT.AHIT) RETUR... | using System.Collections.Generic;
using System.IO;
class Program {
static void Main() {
var files = new List<string> {
"test1.txt",
"test2.txt"
};
foreach (string file in files) {
File.WriteAllText(file, File.ReadAllText(file).Replace("Goodbye London!", "... |
Port the following code from Fortran to C++ with equivalent syntax and logic. | SUBROUTINE FILEHACK(FNAME,THIS,THAT)
CHARACTER*(*) FNAME
CHARACTER*(*) THIS
CHARACTER*(*) THAT
INTEGER F,T
PARAMETER (F=66,T=67)
INTEGER L
CHARACTER*6666 ALINE
LOGICAL AHIT
INQUIRE(FILE = FNAME, EXIST = AHIT)
IF (.NOT.AHIT) RETUR... | #include <fstream>
#include <iterator>
#include <boost/regex.hpp>
#include <string>
#include <iostream>
int main( int argc , char *argv[ ] ) {
boost::regex to_be_replaced( "Goodbye London\\s*!" ) ;
std::string replacement( "Hello New York!" ) ;
for ( int i = 1 ; i < argc ; i++ ) {
std::ifstream infile (... |
Write the same algorithm in C++ as shown in this Fortran implementation. | SUBROUTINE FILEHACK(FNAME,THIS,THAT)
CHARACTER*(*) FNAME
CHARACTER*(*) THIS
CHARACTER*(*) THAT
INTEGER F,T
PARAMETER (F=66,T=67)
INTEGER L
CHARACTER*6666 ALINE
LOGICAL AHIT
INQUIRE(FILE = FNAME, EXIST = AHIT)
IF (.NOT.AHIT) RETUR... | #include <fstream>
#include <iterator>
#include <boost/regex.hpp>
#include <string>
#include <iostream>
int main( int argc , char *argv[ ] ) {
boost::regex to_be_replaced( "Goodbye London\\s*!" ) ;
std::string replacement( "Hello New York!" ) ;
for ( int i = 1 ; i < argc ; i++ ) {
std::ifstream infile (... |
Produce a language-to-language conversion: from Fortran to C, same semantics. | SUBROUTINE FILEHACK(FNAME,THIS,THAT)
CHARACTER*(*) FNAME
CHARACTER*(*) THIS
CHARACTER*(*) THAT
INTEGER F,T
PARAMETER (F=66,T=67)
INTEGER L
CHARACTER*6666 ALINE
LOGICAL AHIT
INQUIRE(FILE = FNAME, EXIST = AHIT)
IF (.NOT.AHIT) RETUR... | #include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <sys/types.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <unistd.h>
#include <err.h>
#include <string.h>
char * find_match(const char *buf, const char * buf_end, const char *pat, size_t len)
{
ptrdiff_t i;
char *start = bu... |
Can you help me rewrite this code in C instead of Fortran, keeping it the same logically? | SUBROUTINE FILEHACK(FNAME,THIS,THAT)
CHARACTER*(*) FNAME
CHARACTER*(*) THIS
CHARACTER*(*) THAT
INTEGER F,T
PARAMETER (F=66,T=67)
INTEGER L
CHARACTER*6666 ALINE
LOGICAL AHIT
INQUIRE(FILE = FNAME, EXIST = AHIT)
IF (.NOT.AHIT) RETUR... | #include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <sys/types.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <unistd.h>
#include <err.h>
#include <string.h>
char * find_match(const char *buf, const char * buf_end, const char *pat, size_t len)
{
ptrdiff_t i;
char *start = bu... |
Convert this Fortran block to Java, preserving its control flow and logic. | SUBROUTINE FILEHACK(FNAME,THIS,THAT)
CHARACTER*(*) FNAME
CHARACTER*(*) THIS
CHARACTER*(*) THAT
INTEGER F,T
PARAMETER (F=66,T=67)
INTEGER L
CHARACTER*6666 ALINE
LOGICAL AHIT
INQUIRE(FILE = FNAME, EXIST = AHIT)
IF (.NOT.AHIT) RETUR... | import java.io.*;
import java.nio.file.*;
public class GloballyReplaceText {
public static void main(String[] args) throws IOException {
for (String fn : new String[]{"test1.txt", "test2.txt"}) {
String s = new String(Files.readAllBytes(Paths.get(fn)));
s = s.replace("Goodbye Lond... |
Write the same algorithm in Java as shown in this Fortran implementation. | SUBROUTINE FILEHACK(FNAME,THIS,THAT)
CHARACTER*(*) FNAME
CHARACTER*(*) THIS
CHARACTER*(*) THAT
INTEGER F,T
PARAMETER (F=66,T=67)
INTEGER L
CHARACTER*6666 ALINE
LOGICAL AHIT
INQUIRE(FILE = FNAME, EXIST = AHIT)
IF (.NOT.AHIT) RETUR... | import java.io.*;
import java.nio.file.*;
public class GloballyReplaceText {
public static void main(String[] args) throws IOException {
for (String fn : new String[]{"test1.txt", "test2.txt"}) {
String s = new String(Files.readAllBytes(Paths.get(fn)));
s = s.replace("Goodbye Lond... |
Change the following Fortran code into Python without altering its purpose. | SUBROUTINE FILEHACK(FNAME,THIS,THAT)
CHARACTER*(*) FNAME
CHARACTER*(*) THIS
CHARACTER*(*) THAT
INTEGER F,T
PARAMETER (F=66,T=67)
INTEGER L
CHARACTER*6666 ALINE
LOGICAL AHIT
INQUIRE(FILE = FNAME, EXIST = AHIT)
IF (.NOT.AHIT) RETUR... | import fileinput
for line in fileinput.input(inplace=True):
print(line.replace('Goodbye London!', 'Hello New York!'), end='')
|
Port the following code from Fortran to Python with equivalent syntax and logic. | SUBROUTINE FILEHACK(FNAME,THIS,THAT)
CHARACTER*(*) FNAME
CHARACTER*(*) THIS
CHARACTER*(*) THAT
INTEGER F,T
PARAMETER (F=66,T=67)
INTEGER L
CHARACTER*6666 ALINE
LOGICAL AHIT
INQUIRE(FILE = FNAME, EXIST = AHIT)
IF (.NOT.AHIT) RETUR... | import fileinput
for line in fileinput.input(inplace=True):
print(line.replace('Goodbye London!', 'Hello New York!'), end='')
|
Write the same algorithm in C as shown in this Haskell implementation. | import Data.List (tails, elemIndices, isPrefixOf)
replace :: String -> String -> String -> String
replace [] _ xs = xs
replace _ [] xs = xs
replace _ _ [] = []
replace a b xs = replAll
where
xtails = tails xs
matches = elemIndices True $ map (isPrefixOf a) xtails
... | #include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <sys/types.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <unistd.h>
#include <err.h>
#include <string.h>
char * find_match(const char *buf, const char * buf_end, const char *pat, size_t len)
{
ptrdiff_t i;
char *start = bu... |
Please provide an equivalent version of this Haskell code in C. | import Data.List (tails, elemIndices, isPrefixOf)
replace :: String -> String -> String -> String
replace [] _ xs = xs
replace _ [] xs = xs
replace _ _ [] = []
replace a b xs = replAll
where
xtails = tails xs
matches = elemIndices True $ map (isPrefixOf a) xtails
... | #include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <sys/types.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <unistd.h>
#include <err.h>
#include <string.h>
char * find_match(const char *buf, const char * buf_end, const char *pat, size_t len)
{
ptrdiff_t i;
char *start = bu... |
Convert this Haskell block to C#, preserving its control flow and logic. | import Data.List (tails, elemIndices, isPrefixOf)
replace :: String -> String -> String -> String
replace [] _ xs = xs
replace _ [] xs = xs
replace _ _ [] = []
replace a b xs = replAll
where
xtails = tails xs
matches = elemIndices True $ map (isPrefixOf a) xtails
... | using System.Collections.Generic;
using System.IO;
class Program {
static void Main() {
var files = new List<string> {
"test1.txt",
"test2.txt"
};
foreach (string file in files) {
File.WriteAllText(file, File.ReadAllText(file).Replace("Goodbye London!", "... |
Convert the following code from Haskell to C#, ensuring the logic remains intact. | import Data.List (tails, elemIndices, isPrefixOf)
replace :: String -> String -> String -> String
replace [] _ xs = xs
replace _ [] xs = xs
replace _ _ [] = []
replace a b xs = replAll
where
xtails = tails xs
matches = elemIndices True $ map (isPrefixOf a) xtails
... | using System.Collections.Generic;
using System.IO;
class Program {
static void Main() {
var files = new List<string> {
"test1.txt",
"test2.txt"
};
foreach (string file in files) {
File.WriteAllText(file, File.ReadAllText(file).Replace("Goodbye London!", "... |
Write the same algorithm in C++ as shown in this Haskell implementation. | import Data.List (tails, elemIndices, isPrefixOf)
replace :: String -> String -> String -> String
replace [] _ xs = xs
replace _ [] xs = xs
replace _ _ [] = []
replace a b xs = replAll
where
xtails = tails xs
matches = elemIndices True $ map (isPrefixOf a) xtails
... | #include <fstream>
#include <iterator>
#include <boost/regex.hpp>
#include <string>
#include <iostream>
int main( int argc , char *argv[ ] ) {
boost::regex to_be_replaced( "Goodbye London\\s*!" ) ;
std::string replacement( "Hello New York!" ) ;
for ( int i = 1 ; i < argc ; i++ ) {
std::ifstream infile (... |
Write the same code in C++ as shown below in Haskell. | import Data.List (tails, elemIndices, isPrefixOf)
replace :: String -> String -> String -> String
replace [] _ xs = xs
replace _ [] xs = xs
replace _ _ [] = []
replace a b xs = replAll
where
xtails = tails xs
matches = elemIndices True $ map (isPrefixOf a) xtails
... | #include <fstream>
#include <iterator>
#include <boost/regex.hpp>
#include <string>
#include <iostream>
int main( int argc , char *argv[ ] ) {
boost::regex to_be_replaced( "Goodbye London\\s*!" ) ;
std::string replacement( "Hello New York!" ) ;
for ( int i = 1 ; i < argc ; i++ ) {
std::ifstream infile (... |
Produce a functionally identical Java code for the snippet given in Haskell. | import Data.List (tails, elemIndices, isPrefixOf)
replace :: String -> String -> String -> String
replace [] _ xs = xs
replace _ [] xs = xs
replace _ _ [] = []
replace a b xs = replAll
where
xtails = tails xs
matches = elemIndices True $ map (isPrefixOf a) xtails
... | import java.io.*;
import java.nio.file.*;
public class GloballyReplaceText {
public static void main(String[] args) throws IOException {
for (String fn : new String[]{"test1.txt", "test2.txt"}) {
String s = new String(Files.readAllBytes(Paths.get(fn)));
s = s.replace("Goodbye Lond... |
Ensure the translated Java code behaves exactly like the original Haskell snippet. | import Data.List (tails, elemIndices, isPrefixOf)
replace :: String -> String -> String -> String
replace [] _ xs = xs
replace _ [] xs = xs
replace _ _ [] = []
replace a b xs = replAll
where
xtails = tails xs
matches = elemIndices True $ map (isPrefixOf a) xtails
... | import java.io.*;
import java.nio.file.*;
public class GloballyReplaceText {
public static void main(String[] args) throws IOException {
for (String fn : new String[]{"test1.txt", "test2.txt"}) {
String s = new String(Files.readAllBytes(Paths.get(fn)));
s = s.replace("Goodbye Lond... |
Rewrite this program in Python while keeping its functionality equivalent to the Haskell version. | import Data.List (tails, elemIndices, isPrefixOf)
replace :: String -> String -> String -> String
replace [] _ xs = xs
replace _ [] xs = xs
replace _ _ [] = []
replace a b xs = replAll
where
xtails = tails xs
matches = elemIndices True $ map (isPrefixOf a) xtails
... | import fileinput
for line in fileinput.input(inplace=True):
print(line.replace('Goodbye London!', 'Hello New York!'), end='')
|
Can you help me rewrite this code in Python instead of Haskell, keeping it the same logically? | import Data.List (tails, elemIndices, isPrefixOf)
replace :: String -> String -> String -> String
replace [] _ xs = xs
replace _ [] xs = xs
replace _ _ [] = []
replace a b xs = replAll
where
xtails = tails xs
matches = elemIndices True $ map (isPrefixOf a) xtails
... | import fileinput
for line in fileinput.input(inplace=True):
print(line.replace('Goodbye London!', 'Hello New York!'), end='')
|
Can you help me rewrite this code in Go instead of Haskell, keeping it the same logically? | import Data.List (tails, elemIndices, isPrefixOf)
replace :: String -> String -> String -> String
replace [] _ xs = xs
replace _ [] xs = xs
replace _ _ [] = []
replace a b xs = replAll
where
xtails = tails xs
matches = elemIndices True $ map (isPrefixOf a) xtails
... | package main
import (
"bytes"
"io/ioutil"
"log"
"os"
)
func main() {
gRepNFiles("Goodbye London!", "Hello New York!", []string{
"a.txt",
"b.txt",
"c.txt",
})
}
func gRepNFiles(olds, news string, files []string) {
oldb := []byte(olds)
newb := []byte(news)
fo... |
Write a version of this Haskell function in Go with identical behavior. | import Data.List (tails, elemIndices, isPrefixOf)
replace :: String -> String -> String -> String
replace [] _ xs = xs
replace _ [] xs = xs
replace _ _ [] = []
replace a b xs = replAll
where
xtails = tails xs
matches = elemIndices True $ map (isPrefixOf a) xtails
... | package main
import (
"bytes"
"io/ioutil"
"log"
"os"
)
func main() {
gRepNFiles("Goodbye London!", "Hello New York!", []string{
"a.txt",
"b.txt",
"c.txt",
})
}
func gRepNFiles(olds, news string, files []string) {
oldb := []byte(olds)
newb := []byte(news)
fo... |
Preserve the algorithm and functionality while converting the code from Icon to C. | procedure main()
globalrepl("Goodbye London","Hello New York","a.txt","b.txt")
end
procedure globalrepl(old,new,files[])
every fn := !files do
if s := reads(f := open(fn,"bu"),stat(f).size) then {
writes(seek(f,1),replace(s,old,new))
close(f)
}
else write(&errout,"Unable to open ",fn)
end
... | #include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <sys/types.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <unistd.h>
#include <err.h>
#include <string.h>
char * find_match(const char *buf, const char * buf_end, const char *pat, size_t len)
{
ptrdiff_t i;
char *start = bu... |
Write a version of this Icon function in C with identical behavior. | procedure main()
globalrepl("Goodbye London","Hello New York","a.txt","b.txt")
end
procedure globalrepl(old,new,files[])
every fn := !files do
if s := reads(f := open(fn,"bu"),stat(f).size) then {
writes(seek(f,1),replace(s,old,new))
close(f)
}
else write(&errout,"Unable to open ",fn)
end
... | #include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <sys/types.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <unistd.h>
#include <err.h>
#include <string.h>
char * find_match(const char *buf, const char * buf_end, const char *pat, size_t len)
{
ptrdiff_t i;
char *start = bu... |
Change the programming language of this snippet from Icon to C# without modifying what it does. | procedure main()
globalrepl("Goodbye London","Hello New York","a.txt","b.txt")
end
procedure globalrepl(old,new,files[])
every fn := !files do
if s := reads(f := open(fn,"bu"),stat(f).size) then {
writes(seek(f,1),replace(s,old,new))
close(f)
}
else write(&errout,"Unable to open ",fn)
end
... | using System.Collections.Generic;
using System.IO;
class Program {
static void Main() {
var files = new List<string> {
"test1.txt",
"test2.txt"
};
foreach (string file in files) {
File.WriteAllText(file, File.ReadAllText(file).Replace("Goodbye London!", "... |
Transform the following Icon implementation into C#, maintaining the same output and logic. | procedure main()
globalrepl("Goodbye London","Hello New York","a.txt","b.txt")
end
procedure globalrepl(old,new,files[])
every fn := !files do
if s := reads(f := open(fn,"bu"),stat(f).size) then {
writes(seek(f,1),replace(s,old,new))
close(f)
}
else write(&errout,"Unable to open ",fn)
end
... | using System.Collections.Generic;
using System.IO;
class Program {
static void Main() {
var files = new List<string> {
"test1.txt",
"test2.txt"
};
foreach (string file in files) {
File.WriteAllText(file, File.ReadAllText(file).Replace("Goodbye London!", "... |
Translate this program into C++ but keep the logic exactly as in Icon. | procedure main()
globalrepl("Goodbye London","Hello New York","a.txt","b.txt")
end
procedure globalrepl(old,new,files[])
every fn := !files do
if s := reads(f := open(fn,"bu"),stat(f).size) then {
writes(seek(f,1),replace(s,old,new))
close(f)
}
else write(&errout,"Unable to open ",fn)
end
... | #include <fstream>
#include <iterator>
#include <boost/regex.hpp>
#include <string>
#include <iostream>
int main( int argc , char *argv[ ] ) {
boost::regex to_be_replaced( "Goodbye London\\s*!" ) ;
std::string replacement( "Hello New York!" ) ;
for ( int i = 1 ; i < argc ; i++ ) {
std::ifstream infile (... |
Convert this Icon snippet to C++ and keep its semantics consistent. | procedure main()
globalrepl("Goodbye London","Hello New York","a.txt","b.txt")
end
procedure globalrepl(old,new,files[])
every fn := !files do
if s := reads(f := open(fn,"bu"),stat(f).size) then {
writes(seek(f,1),replace(s,old,new))
close(f)
}
else write(&errout,"Unable to open ",fn)
end
... | #include <fstream>
#include <iterator>
#include <boost/regex.hpp>
#include <string>
#include <iostream>
int main( int argc , char *argv[ ] ) {
boost::regex to_be_replaced( "Goodbye London\\s*!" ) ;
std::string replacement( "Hello New York!" ) ;
for ( int i = 1 ; i < argc ; i++ ) {
std::ifstream infile (... |
Preserve the algorithm and functionality while converting the code from Icon to Java. | procedure main()
globalrepl("Goodbye London","Hello New York","a.txt","b.txt")
end
procedure globalrepl(old,new,files[])
every fn := !files do
if s := reads(f := open(fn,"bu"),stat(f).size) then {
writes(seek(f,1),replace(s,old,new))
close(f)
}
else write(&errout,"Unable to open ",fn)
end
... | import java.io.*;
import java.nio.file.*;
public class GloballyReplaceText {
public static void main(String[] args) throws IOException {
for (String fn : new String[]{"test1.txt", "test2.txt"}) {
String s = new String(Files.readAllBytes(Paths.get(fn)));
s = s.replace("Goodbye Lond... |
Rewrite this program in Java while keeping its functionality equivalent to the Icon version. | procedure main()
globalrepl("Goodbye London","Hello New York","a.txt","b.txt")
end
procedure globalrepl(old,new,files[])
every fn := !files do
if s := reads(f := open(fn,"bu"),stat(f).size) then {
writes(seek(f,1),replace(s,old,new))
close(f)
}
else write(&errout,"Unable to open ",fn)
end
... | import java.io.*;
import java.nio.file.*;
public class GloballyReplaceText {
public static void main(String[] args) throws IOException {
for (String fn : new String[]{"test1.txt", "test2.txt"}) {
String s = new String(Files.readAllBytes(Paths.get(fn)));
s = s.replace("Goodbye Lond... |
Produce a functionally identical Python code for the snippet given in Icon. | procedure main()
globalrepl("Goodbye London","Hello New York","a.txt","b.txt")
end
procedure globalrepl(old,new,files[])
every fn := !files do
if s := reads(f := open(fn,"bu"),stat(f).size) then {
writes(seek(f,1),replace(s,old,new))
close(f)
}
else write(&errout,"Unable to open ",fn)
end
... | import fileinput
for line in fileinput.input(inplace=True):
print(line.replace('Goodbye London!', 'Hello New York!'), end='')
|
Can you help me rewrite this code in Python instead of Icon, keeping it the same logically? | procedure main()
globalrepl("Goodbye London","Hello New York","a.txt","b.txt")
end
procedure globalrepl(old,new,files[])
every fn := !files do
if s := reads(f := open(fn,"bu"),stat(f).size) then {
writes(seek(f,1),replace(s,old,new))
close(f)
}
else write(&errout,"Unable to open ",fn)
end
... | import fileinput
for line in fileinput.input(inplace=True):
print(line.replace('Goodbye London!', 'Hello New York!'), end='')
|
Translate the given Icon code snippet into Go without altering its behavior. | procedure main()
globalrepl("Goodbye London","Hello New York","a.txt","b.txt")
end
procedure globalrepl(old,new,files[])
every fn := !files do
if s := reads(f := open(fn,"bu"),stat(f).size) then {
writes(seek(f,1),replace(s,old,new))
close(f)
}
else write(&errout,"Unable to open ",fn)
end
... | package main
import (
"bytes"
"io/ioutil"
"log"
"os"
)
func main() {
gRepNFiles("Goodbye London!", "Hello New York!", []string{
"a.txt",
"b.txt",
"c.txt",
})
}
func gRepNFiles(olds, news string, files []string) {
oldb := []byte(olds)
newb := []byte(news)
fo... |
Convert this Icon snippet to Go and keep its semantics consistent. | procedure main()
globalrepl("Goodbye London","Hello New York","a.txt","b.txt")
end
procedure globalrepl(old,new,files[])
every fn := !files do
if s := reads(f := open(fn,"bu"),stat(f).size) then {
writes(seek(f,1),replace(s,old,new))
close(f)
}
else write(&errout,"Unable to open ",fn)
end
... | package main
import (
"bytes"
"io/ioutil"
"log"
"os"
)
func main() {
gRepNFiles("Goodbye London!", "Hello New York!", []string{
"a.txt",
"b.txt",
"c.txt",
})
}
func gRepNFiles(olds, news string, files []string) {
oldb := []byte(olds)
newb := []byte(news)
fo... |
Translate this program into C but keep the logic exactly as in J. | require'strings'
(1!:2~rplc&('Goodbye London!';'Hello New York!')@(1!:1))"0 files
| #include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <sys/types.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <unistd.h>
#include <err.h>
#include <string.h>
char * find_match(const char *buf, const char * buf_end, const char *pat, size_t len)
{
ptrdiff_t i;
char *start = bu... |
Generate a C translation of this J snippet without changing its computational steps. | require'strings'
(1!:2~rplc&('Goodbye London!';'Hello New York!')@(1!:1))"0 files
| #include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <sys/types.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <unistd.h>
#include <err.h>
#include <string.h>
char * find_match(const char *buf, const char * buf_end, const char *pat, size_t len)
{
ptrdiff_t i;
char *start = bu... |
Convert the following code from J to C#, ensuring the logic remains intact. | require'strings'
(1!:2~rplc&('Goodbye London!';'Hello New York!')@(1!:1))"0 files
| using System.Collections.Generic;
using System.IO;
class Program {
static void Main() {
var files = new List<string> {
"test1.txt",
"test2.txt"
};
foreach (string file in files) {
File.WriteAllText(file, File.ReadAllText(file).Replace("Goodbye London!", "... |
Write a version of this J function in C# with identical behavior. | require'strings'
(1!:2~rplc&('Goodbye London!';'Hello New York!')@(1!:1))"0 files
| using System.Collections.Generic;
using System.IO;
class Program {
static void Main() {
var files = new List<string> {
"test1.txt",
"test2.txt"
};
foreach (string file in files) {
File.WriteAllText(file, File.ReadAllText(file).Replace("Goodbye London!", "... |
Transform the following J implementation into C++, maintaining the same output and logic. | require'strings'
(1!:2~rplc&('Goodbye London!';'Hello New York!')@(1!:1))"0 files
| #include <fstream>
#include <iterator>
#include <boost/regex.hpp>
#include <string>
#include <iostream>
int main( int argc , char *argv[ ] ) {
boost::regex to_be_replaced( "Goodbye London\\s*!" ) ;
std::string replacement( "Hello New York!" ) ;
for ( int i = 1 ; i < argc ; i++ ) {
std::ifstream infile (... |
Change the following J code into C++ without altering its purpose. | require'strings'
(1!:2~rplc&('Goodbye London!';'Hello New York!')@(1!:1))"0 files
| #include <fstream>
#include <iterator>
#include <boost/regex.hpp>
#include <string>
#include <iostream>
int main( int argc , char *argv[ ] ) {
boost::regex to_be_replaced( "Goodbye London\\s*!" ) ;
std::string replacement( "Hello New York!" ) ;
for ( int i = 1 ; i < argc ; i++ ) {
std::ifstream infile (... |
Write a version of this J function in Java with identical behavior. | require'strings'
(1!:2~rplc&('Goodbye London!';'Hello New York!')@(1!:1))"0 files
| import java.io.*;
import java.nio.file.*;
public class GloballyReplaceText {
public static void main(String[] args) throws IOException {
for (String fn : new String[]{"test1.txt", "test2.txt"}) {
String s = new String(Files.readAllBytes(Paths.get(fn)));
s = s.replace("Goodbye Lond... |
Can you help me rewrite this code in Java instead of J, keeping it the same logically? | require'strings'
(1!:2~rplc&('Goodbye London!';'Hello New York!')@(1!:1))"0 files
| import java.io.*;
import java.nio.file.*;
public class GloballyReplaceText {
public static void main(String[] args) throws IOException {
for (String fn : new String[]{"test1.txt", "test2.txt"}) {
String s = new String(Files.readAllBytes(Paths.get(fn)));
s = s.replace("Goodbye Lond... |
Convert this J block to Python, preserving its control flow and logic. | require'strings'
(1!:2~rplc&('Goodbye London!';'Hello New York!')@(1!:1))"0 files
| import fileinput
for line in fileinput.input(inplace=True):
print(line.replace('Goodbye London!', 'Hello New York!'), end='')
|
Maintain the same structure and functionality when rewriting this code in Python. | require'strings'
(1!:2~rplc&('Goodbye London!';'Hello New York!')@(1!:1))"0 files
| import fileinput
for line in fileinput.input(inplace=True):
print(line.replace('Goodbye London!', 'Hello New York!'), end='')
|
Produce a language-to-language conversion: from J to Go, same semantics. | require'strings'
(1!:2~rplc&('Goodbye London!';'Hello New York!')@(1!:1))"0 files
| package main
import (
"bytes"
"io/ioutil"
"log"
"os"
)
func main() {
gRepNFiles("Goodbye London!", "Hello New York!", []string{
"a.txt",
"b.txt",
"c.txt",
})
}
func gRepNFiles(olds, news string, files []string) {
oldb := []byte(olds)
newb := []byte(news)
fo... |
Keep all operations the same but rewrite the snippet in Go. | require'strings'
(1!:2~rplc&('Goodbye London!';'Hello New York!')@(1!:1))"0 files
| package main
import (
"bytes"
"io/ioutil"
"log"
"os"
)
func main() {
gRepNFiles("Goodbye London!", "Hello New York!", []string{
"a.txt",
"b.txt",
"c.txt",
})
}
func gRepNFiles(olds, news string, files []string) {
oldb := []byte(olds)
newb := []byte(news)
fo... |
Change the following Julia code into C without altering its purpose. | filenames = ["f1.txt", "f2.txt"]
for filename in filenames
txt = read(filename, String)
open(filename, "w") do f
write(f, replace(txt, "Goodbye London!" => "Hello New York!"))
end
end
| #include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <sys/types.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <unistd.h>
#include <err.h>
#include <string.h>
char * find_match(const char *buf, const char * buf_end, const char *pat, size_t len)
{
ptrdiff_t i;
char *start = bu... |
Produce a language-to-language conversion: from Julia to C, same semantics. | filenames = ["f1.txt", "f2.txt"]
for filename in filenames
txt = read(filename, String)
open(filename, "w") do f
write(f, replace(txt, "Goodbye London!" => "Hello New York!"))
end
end
| #include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <sys/types.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <unistd.h>
#include <err.h>
#include <string.h>
char * find_match(const char *buf, const char * buf_end, const char *pat, size_t len)
{
ptrdiff_t i;
char *start = bu... |
Preserve the algorithm and functionality while converting the code from Julia to C#. | filenames = ["f1.txt", "f2.txt"]
for filename in filenames
txt = read(filename, String)
open(filename, "w") do f
write(f, replace(txt, "Goodbye London!" => "Hello New York!"))
end
end
| using System.Collections.Generic;
using System.IO;
class Program {
static void Main() {
var files = new List<string> {
"test1.txt",
"test2.txt"
};
foreach (string file in files) {
File.WriteAllText(file, File.ReadAllText(file).Replace("Goodbye London!", "... |
Produce a functionally identical C# code for the snippet given in Julia. | filenames = ["f1.txt", "f2.txt"]
for filename in filenames
txt = read(filename, String)
open(filename, "w") do f
write(f, replace(txt, "Goodbye London!" => "Hello New York!"))
end
end
| using System.Collections.Generic;
using System.IO;
class Program {
static void Main() {
var files = new List<string> {
"test1.txt",
"test2.txt"
};
foreach (string file in files) {
File.WriteAllText(file, File.ReadAllText(file).Replace("Goodbye London!", "... |
Port the following code from Julia to C++ with equivalent syntax and logic. | filenames = ["f1.txt", "f2.txt"]
for filename in filenames
txt = read(filename, String)
open(filename, "w") do f
write(f, replace(txt, "Goodbye London!" => "Hello New York!"))
end
end
| #include <fstream>
#include <iterator>
#include <boost/regex.hpp>
#include <string>
#include <iostream>
int main( int argc , char *argv[ ] ) {
boost::regex to_be_replaced( "Goodbye London\\s*!" ) ;
std::string replacement( "Hello New York!" ) ;
for ( int i = 1 ; i < argc ; i++ ) {
std::ifstream infile (... |
Convert the following code from Julia to C++, ensuring the logic remains intact. | filenames = ["f1.txt", "f2.txt"]
for filename in filenames
txt = read(filename, String)
open(filename, "w") do f
write(f, replace(txt, "Goodbye London!" => "Hello New York!"))
end
end
| #include <fstream>
#include <iterator>
#include <boost/regex.hpp>
#include <string>
#include <iostream>
int main( int argc , char *argv[ ] ) {
boost::regex to_be_replaced( "Goodbye London\\s*!" ) ;
std::string replacement( "Hello New York!" ) ;
for ( int i = 1 ; i < argc ; i++ ) {
std::ifstream infile (... |
Ensure the translated Java code behaves exactly like the original Julia snippet. | filenames = ["f1.txt", "f2.txt"]
for filename in filenames
txt = read(filename, String)
open(filename, "w") do f
write(f, replace(txt, "Goodbye London!" => "Hello New York!"))
end
end
| import java.io.*;
import java.nio.file.*;
public class GloballyReplaceText {
public static void main(String[] args) throws IOException {
for (String fn : new String[]{"test1.txt", "test2.txt"}) {
String s = new String(Files.readAllBytes(Paths.get(fn)));
s = s.replace("Goodbye Lond... |
Rewrite this program in Java while keeping its functionality equivalent to the Julia version. | filenames = ["f1.txt", "f2.txt"]
for filename in filenames
txt = read(filename, String)
open(filename, "w") do f
write(f, replace(txt, "Goodbye London!" => "Hello New York!"))
end
end
| import java.io.*;
import java.nio.file.*;
public class GloballyReplaceText {
public static void main(String[] args) throws IOException {
for (String fn : new String[]{"test1.txt", "test2.txt"}) {
String s = new String(Files.readAllBytes(Paths.get(fn)));
s = s.replace("Goodbye Lond... |
Port the provided Julia code into Python while preserving the original functionality. | filenames = ["f1.txt", "f2.txt"]
for filename in filenames
txt = read(filename, String)
open(filename, "w") do f
write(f, replace(txt, "Goodbye London!" => "Hello New York!"))
end
end
| import fileinput
for line in fileinput.input(inplace=True):
print(line.replace('Goodbye London!', 'Hello New York!'), end='')
|
Generate a Go translation of this Julia snippet without changing its computational steps. | filenames = ["f1.txt", "f2.txt"]
for filename in filenames
txt = read(filename, String)
open(filename, "w") do f
write(f, replace(txt, "Goodbye London!" => "Hello New York!"))
end
end
| package main
import (
"bytes"
"io/ioutil"
"log"
"os"
)
func main() {
gRepNFiles("Goodbye London!", "Hello New York!", []string{
"a.txt",
"b.txt",
"c.txt",
})
}
func gRepNFiles(olds, news string, files []string) {
oldb := []byte(olds)
newb := []byte(news)
fo... |
Convert the following code from Julia to Go, ensuring the logic remains intact. | filenames = ["f1.txt", "f2.txt"]
for filename in filenames
txt = read(filename, String)
open(filename, "w") do f
write(f, replace(txt, "Goodbye London!" => "Hello New York!"))
end
end
| package main
import (
"bytes"
"io/ioutil"
"log"
"os"
)
func main() {
gRepNFiles("Goodbye London!", "Hello New York!", []string{
"a.txt",
"b.txt",
"c.txt",
})
}
func gRepNFiles(olds, news string, files []string) {
oldb := []byte(olds)
newb := []byte(news)
fo... |
Can you help me rewrite this code in C instead of Lua, keeping it the same logically? | filenames = { "f1.txt", "f2.txt" }
for _, fn in pairs( filenames ) do
fp = io.open( fn, "r" )
str = fp:read( "*all" )
str = string.gsub( str, "Goodbye London!", "Hello New York!" )
fp:close()
fp = io.open( fn, "w+" )
fp:write( str )
fp:close()
end
| #include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <sys/types.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <unistd.h>
#include <err.h>
#include <string.h>
char * find_match(const char *buf, const char * buf_end, const char *pat, size_t len)
{
ptrdiff_t i;
char *start = bu... |
Translate the given Lua code snippet into C without altering its behavior. | filenames = { "f1.txt", "f2.txt" }
for _, fn in pairs( filenames ) do
fp = io.open( fn, "r" )
str = fp:read( "*all" )
str = string.gsub( str, "Goodbye London!", "Hello New York!" )
fp:close()
fp = io.open( fn, "w+" )
fp:write( str )
fp:close()
end
| #include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <sys/types.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <unistd.h>
#include <err.h>
#include <string.h>
char * find_match(const char *buf, const char * buf_end, const char *pat, size_t len)
{
ptrdiff_t i;
char *start = bu... |
Port the following code from Lua to C# with equivalent syntax and logic. | filenames = { "f1.txt", "f2.txt" }
for _, fn in pairs( filenames ) do
fp = io.open( fn, "r" )
str = fp:read( "*all" )
str = string.gsub( str, "Goodbye London!", "Hello New York!" )
fp:close()
fp = io.open( fn, "w+" )
fp:write( str )
fp:close()
end
| using System.Collections.Generic;
using System.IO;
class Program {
static void Main() {
var files = new List<string> {
"test1.txt",
"test2.txt"
};
foreach (string file in files) {
File.WriteAllText(file, File.ReadAllText(file).Replace("Goodbye London!", "... |
Port the provided Lua code into C# while preserving the original functionality. | filenames = { "f1.txt", "f2.txt" }
for _, fn in pairs( filenames ) do
fp = io.open( fn, "r" )
str = fp:read( "*all" )
str = string.gsub( str, "Goodbye London!", "Hello New York!" )
fp:close()
fp = io.open( fn, "w+" )
fp:write( str )
fp:close()
end
| using System.Collections.Generic;
using System.IO;
class Program {
static void Main() {
var files = new List<string> {
"test1.txt",
"test2.txt"
};
foreach (string file in files) {
File.WriteAllText(file, File.ReadAllText(file).Replace("Goodbye London!", "... |
Convert the following code from Lua to C++, ensuring the logic remains intact. | filenames = { "f1.txt", "f2.txt" }
for _, fn in pairs( filenames ) do
fp = io.open( fn, "r" )
str = fp:read( "*all" )
str = string.gsub( str, "Goodbye London!", "Hello New York!" )
fp:close()
fp = io.open( fn, "w+" )
fp:write( str )
fp:close()
end
| #include <fstream>
#include <iterator>
#include <boost/regex.hpp>
#include <string>
#include <iostream>
int main( int argc , char *argv[ ] ) {
boost::regex to_be_replaced( "Goodbye London\\s*!" ) ;
std::string replacement( "Hello New York!" ) ;
for ( int i = 1 ; i < argc ; i++ ) {
std::ifstream infile (... |
Transform the following Lua implementation into C++, maintaining the same output and logic. | filenames = { "f1.txt", "f2.txt" }
for _, fn in pairs( filenames ) do
fp = io.open( fn, "r" )
str = fp:read( "*all" )
str = string.gsub( str, "Goodbye London!", "Hello New York!" )
fp:close()
fp = io.open( fn, "w+" )
fp:write( str )
fp:close()
end
| #include <fstream>
#include <iterator>
#include <boost/regex.hpp>
#include <string>
#include <iostream>
int main( int argc , char *argv[ ] ) {
boost::regex to_be_replaced( "Goodbye London\\s*!" ) ;
std::string replacement( "Hello New York!" ) ;
for ( int i = 1 ; i < argc ; i++ ) {
std::ifstream infile (... |
Generate a Java translation of this Lua snippet without changing its computational steps. | filenames = { "f1.txt", "f2.txt" }
for _, fn in pairs( filenames ) do
fp = io.open( fn, "r" )
str = fp:read( "*all" )
str = string.gsub( str, "Goodbye London!", "Hello New York!" )
fp:close()
fp = io.open( fn, "w+" )
fp:write( str )
fp:close()
end
| import java.io.*;
import java.nio.file.*;
public class GloballyReplaceText {
public static void main(String[] args) throws IOException {
for (String fn : new String[]{"test1.txt", "test2.txt"}) {
String s = new String(Files.readAllBytes(Paths.get(fn)));
s = s.replace("Goodbye Lond... |
Write a version of this Lua function in Java with identical behavior. | filenames = { "f1.txt", "f2.txt" }
for _, fn in pairs( filenames ) do
fp = io.open( fn, "r" )
str = fp:read( "*all" )
str = string.gsub( str, "Goodbye London!", "Hello New York!" )
fp:close()
fp = io.open( fn, "w+" )
fp:write( str )
fp:close()
end
| import java.io.*;
import java.nio.file.*;
public class GloballyReplaceText {
public static void main(String[] args) throws IOException {
for (String fn : new String[]{"test1.txt", "test2.txt"}) {
String s = new String(Files.readAllBytes(Paths.get(fn)));
s = s.replace("Goodbye Lond... |
Rewrite the snippet below in Python so it works the same as the original Lua code. | filenames = { "f1.txt", "f2.txt" }
for _, fn in pairs( filenames ) do
fp = io.open( fn, "r" )
str = fp:read( "*all" )
str = string.gsub( str, "Goodbye London!", "Hello New York!" )
fp:close()
fp = io.open( fn, "w+" )
fp:write( str )
fp:close()
end
| import fileinput
for line in fileinput.input(inplace=True):
print(line.replace('Goodbye London!', 'Hello New York!'), end='')
|
Ensure the translated Python code behaves exactly like the original Lua snippet. | filenames = { "f1.txt", "f2.txt" }
for _, fn in pairs( filenames ) do
fp = io.open( fn, "r" )
str = fp:read( "*all" )
str = string.gsub( str, "Goodbye London!", "Hello New York!" )
fp:close()
fp = io.open( fn, "w+" )
fp:write( str )
fp:close()
end
| import fileinput
for line in fileinput.input(inplace=True):
print(line.replace('Goodbye London!', 'Hello New York!'), end='')
|
Write the same algorithm in Go as shown in this Lua implementation. | filenames = { "f1.txt", "f2.txt" }
for _, fn in pairs( filenames ) do
fp = io.open( fn, "r" )
str = fp:read( "*all" )
str = string.gsub( str, "Goodbye London!", "Hello New York!" )
fp:close()
fp = io.open( fn, "w+" )
fp:write( str )
fp:close()
end
| package main
import (
"bytes"
"io/ioutil"
"log"
"os"
)
func main() {
gRepNFiles("Goodbye London!", "Hello New York!", []string{
"a.txt",
"b.txt",
"c.txt",
})
}
func gRepNFiles(olds, news string, files []string) {
oldb := []byte(olds)
newb := []byte(news)
fo... |
Preserve the algorithm and functionality while converting the code from Lua to Go. | filenames = { "f1.txt", "f2.txt" }
for _, fn in pairs( filenames ) do
fp = io.open( fn, "r" )
str = fp:read( "*all" )
str = string.gsub( str, "Goodbye London!", "Hello New York!" )
fp:close()
fp = io.open( fn, "w+" )
fp:write( str )
fp:close()
end
| package main
import (
"bytes"
"io/ioutil"
"log"
"os"
)
func main() {
gRepNFiles("Goodbye London!", "Hello New York!", []string{
"a.txt",
"b.txt",
"c.txt",
})
}
func gRepNFiles(olds, news string, files []string) {
oldb := []byte(olds)
newb := []byte(news)
fo... |
Port the provided Mathematica code into C while preserving the original functionality. | listOfFiles = {"a.txt", "b.txt", "c.txt"};
Do[
filename = listOfFiles[[i]];
filetext = Import[filename, "Text"];
filetext = StringReplace[filetext, "Goodbye London!" -> "Hello New York!"];
Export[filename, filetext, "Text"]
, {i, 1, Length[listOfFiles]}]
| #include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <sys/types.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <unistd.h>
#include <err.h>
#include <string.h>
char * find_match(const char *buf, const char * buf_end, const char *pat, size_t len)
{
ptrdiff_t i;
char *start = bu... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.