Instruction stringlengths 45 106 | input_code stringlengths 1 13.7k | output_code stringlengths 1 13.7k |
|---|---|---|
Write the same algorithm in C as shown in this Ada implementation. | with Ada.Strings.Unbounded, Ada.Text_IO, Ada.Command_Line, Ada.Directories;
procedure Global_Replace is
subtype U_String is Ada.Strings.Unbounded.Unbounded_String;
function "+"(S: String) return U_String renames
Ada.Strings.Unbounded.To_Unbounded_String;
function "-"(U: U_String) return String renames
... | #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 Ada to C. | with Ada.Strings.Unbounded, Ada.Text_IO, Ada.Command_Line, Ada.Directories;
procedure Global_Replace is
subtype U_String is Ada.Strings.Unbounded.Unbounded_String;
function "+"(S: String) return U_String renames
Ada.Strings.Unbounded.To_Unbounded_String;
function "-"(U: U_String) return String renames
... | #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 Ada snippet to C++ and keep its semantics consistent. | with Ada.Strings.Unbounded, Ada.Text_IO, Ada.Command_Line, Ada.Directories;
procedure Global_Replace is
subtype U_String is Ada.Strings.Unbounded.Unbounded_String;
function "+"(S: String) return U_String renames
Ada.Strings.Unbounded.To_Unbounded_String;
function "-"(U: U_String) return String renames
... | #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 Ada code into C++ while preserving the original functionality. | with Ada.Strings.Unbounded, Ada.Text_IO, Ada.Command_Line, Ada.Directories;
procedure Global_Replace is
subtype U_String is Ada.Strings.Unbounded.Unbounded_String;
function "+"(S: String) return U_String renames
Ada.Strings.Unbounded.To_Unbounded_String;
function "-"(U: U_String) return String renames
... | #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 (... |
Keep all operations the same but rewrite the snippet in Go. | with Ada.Strings.Unbounded, Ada.Text_IO, Ada.Command_Line, Ada.Directories;
procedure Global_Replace is
subtype U_String is Ada.Strings.Unbounded.Unbounded_String;
function "+"(S: String) return U_String renames
Ada.Strings.Unbounded.To_Unbounded_String;
function "-"(U: U_String) return String renames
... | 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 Ada code into Go while preserving the original functionality. | with Ada.Strings.Unbounded, Ada.Text_IO, Ada.Command_Line, Ada.Directories;
procedure Global_Replace is
subtype U_String is Ada.Strings.Unbounded.Unbounded_String;
function "+"(S: String) return U_String renames
Ada.Strings.Unbounded.To_Unbounded_String;
function "-"(U: U_String) return String renames
... | 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 the same algorithm in Java as shown in this Ada implementation. | with Ada.Strings.Unbounded, Ada.Text_IO, Ada.Command_Line, Ada.Directories;
procedure Global_Replace is
subtype U_String is Ada.Strings.Unbounded.Unbounded_String;
function "+"(S: String) return U_String renames
Ada.Strings.Unbounded.To_Unbounded_String;
function "-"(U: U_String) return String renames
... | 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 Ada code into Java while preserving the original functionality. | with Ada.Strings.Unbounded, Ada.Text_IO, Ada.Command_Line, Ada.Directories;
procedure Global_Replace is
subtype U_String is Ada.Strings.Unbounded.Unbounded_String;
function "+"(S: String) return U_String renames
Ada.Strings.Unbounded.To_Unbounded_String;
function "-"(U: U_String) return String renames
... | 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 Ada. | with Ada.Strings.Unbounded, Ada.Text_IO, Ada.Command_Line, Ada.Directories;
procedure Global_Replace is
subtype U_String is Ada.Strings.Unbounded.Unbounded_String;
function "+"(S: String) return U_String renames
Ada.Strings.Unbounded.To_Unbounded_String;
function "-"(U: U_String) return String renames
... | import fileinput
for line in fileinput.input(inplace=True):
print(line.replace('Goodbye London!', 'Hello New York!'), end='')
|
Preserve the algorithm and functionality while converting the code from Ada to Python. | with Ada.Strings.Unbounded, Ada.Text_IO, Ada.Command_Line, Ada.Directories;
procedure Global_Replace is
subtype U_String is Ada.Strings.Unbounded.Unbounded_String;
function "+"(S: String) return U_String renames
Ada.Strings.Unbounded.To_Unbounded_String;
function "-"(U: U_String) return String renames
... | import fileinput
for line in fileinput.input(inplace=True):
print(line.replace('Goodbye London!', 'Hello New York!'), end='')
|
Convert the following code from AutoHotKey to C, ensuring the logic remains intact. | SetWorkingDir %A_ScriptDir%
listFiles := "a.txt|b.txt|c.txt"
loop, Parse, listFiles, |
{
fileread, contents, %A_LoopField%
fileDelete, %A_LoopField%
stringReplace, contents, contents, Goodbye London!, Hello New York!, All
fileAppend, %contents%, %A_LoopField%
}
| #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 AutoHotKey snippet. | SetWorkingDir %A_ScriptDir%
listFiles := "a.txt|b.txt|c.txt"
loop, Parse, listFiles, |
{
fileread, contents, %A_LoopField%
fileDelete, %A_LoopField%
stringReplace, contents, contents, Goodbye London!, Hello New York!, All
fileAppend, %contents%, %A_LoopField%
}
| #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 AutoHotKey function in C# with identical behavior. | SetWorkingDir %A_ScriptDir%
listFiles := "a.txt|b.txt|c.txt"
loop, Parse, listFiles, |
{
fileread, contents, %A_LoopField%
fileDelete, %A_LoopField%
stringReplace, contents, contents, Goodbye London!, Hello New York!, All
fileAppend, %contents%, %A_LoopField%
}
| 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 AutoHotKey to C#. | SetWorkingDir %A_ScriptDir%
listFiles := "a.txt|b.txt|c.txt"
loop, Parse, listFiles, |
{
fileread, contents, %A_LoopField%
fileDelete, %A_LoopField%
stringReplace, contents, contents, Goodbye London!, Hello New York!, All
fileAppend, %contents%, %A_LoopField%
}
| 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!", "... |
Please provide an equivalent version of this AutoHotKey code in C++. | SetWorkingDir %A_ScriptDir%
listFiles := "a.txt|b.txt|c.txt"
loop, Parse, listFiles, |
{
fileread, contents, %A_LoopField%
fileDelete, %A_LoopField%
stringReplace, contents, contents, Goodbye London!, Hello New York!, All
fileAppend, %contents%, %A_LoopField%
}
| #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 (... |
Translate this program into C++ but keep the logic exactly as in AutoHotKey. | SetWorkingDir %A_ScriptDir%
listFiles := "a.txt|b.txt|c.txt"
loop, Parse, listFiles, |
{
fileread, contents, %A_LoopField%
fileDelete, %A_LoopField%
stringReplace, contents, contents, Goodbye London!, Hello New York!, All
fileAppend, %contents%, %A_LoopField%
}
| #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 (... |
Translate the given AutoHotKey code snippet into Java without altering its behavior. | SetWorkingDir %A_ScriptDir%
listFiles := "a.txt|b.txt|c.txt"
loop, Parse, listFiles, |
{
fileread, contents, %A_LoopField%
fileDelete, %A_LoopField%
stringReplace, contents, contents, Goodbye London!, Hello New York!, All
fileAppend, %contents%, %A_LoopField%
}
| 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 an equivalent Java version of this AutoHotKey code. | SetWorkingDir %A_ScriptDir%
listFiles := "a.txt|b.txt|c.txt"
loop, Parse, listFiles, |
{
fileread, contents, %A_LoopField%
fileDelete, %A_LoopField%
stringReplace, contents, contents, Goodbye London!, Hello New York!, All
fileAppend, %contents%, %A_LoopField%
}
| 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 Python code behaves exactly like the original AutoHotKey snippet. | SetWorkingDir %A_ScriptDir%
listFiles := "a.txt|b.txt|c.txt"
loop, Parse, listFiles, |
{
fileread, contents, %A_LoopField%
fileDelete, %A_LoopField%
stringReplace, contents, contents, Goodbye London!, Hello New York!, All
fileAppend, %contents%, %A_LoopField%
}
| import fileinput
for line in fileinput.input(inplace=True):
print(line.replace('Goodbye London!', 'Hello New York!'), end='')
|
Port the provided AutoHotKey code into Python while preserving the original functionality. | SetWorkingDir %A_ScriptDir%
listFiles := "a.txt|b.txt|c.txt"
loop, Parse, listFiles, |
{
fileread, contents, %A_LoopField%
fileDelete, %A_LoopField%
stringReplace, contents, contents, Goodbye London!, Hello New York!, All
fileAppend, %contents%, %A_LoopField%
}
| import fileinput
for line in fileinput.input(inplace=True):
print(line.replace('Goodbye London!', 'Hello New York!'), end='')
|
Generate a Go translation of this AutoHotKey snippet without changing its computational steps. | SetWorkingDir %A_ScriptDir%
listFiles := "a.txt|b.txt|c.txt"
loop, Parse, listFiles, |
{
fileread, contents, %A_LoopField%
fileDelete, %A_LoopField%
stringReplace, contents, contents, Goodbye London!, Hello New York!, All
fileAppend, %contents%, %A_LoopField%
}
| 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... |
Please provide an equivalent version of this AutoHotKey code in Go. | SetWorkingDir %A_ScriptDir%
listFiles := "a.txt|b.txt|c.txt"
loop, Parse, listFiles, |
{
fileread, contents, %A_LoopField%
fileDelete, %A_LoopField%
stringReplace, contents, contents, Goodbye London!, Hello New York!, All
fileAppend, %contents%, %A_LoopField%
}
| 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... |
Rewrite the snippet below in C so it works the same as the original AWK code. |
BEGIN {
old_text = "Goodbye London!"
new_text = "Hello New York!"
}
BEGINFILE {
nfiles_in++
text_found = 0
delete arr
}
{ if (gsub(old_text,new_text,$0) > 0) {
text_found++
}
arr[FNR] = $0
}
ENDFILE {
if (text_found > 0) {
nfiles_out++
close(FILENAME)
for (i=1;... | #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 AWK code into C without altering its purpose. |
BEGIN {
old_text = "Goodbye London!"
new_text = "Hello New York!"
}
BEGINFILE {
nfiles_in++
text_found = 0
delete arr
}
{ if (gsub(old_text,new_text,$0) > 0) {
text_found++
}
arr[FNR] = $0
}
ENDFILE {
if (text_found > 0) {
nfiles_out++
close(FILENAME)
for (i=1;... | #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... |
Transform the following AWK implementation into C#, maintaining the same output and logic. |
BEGIN {
old_text = "Goodbye London!"
new_text = "Hello New York!"
}
BEGINFILE {
nfiles_in++
text_found = 0
delete arr
}
{ if (gsub(old_text,new_text,$0) > 0) {
text_found++
}
arr[FNR] = $0
}
ENDFILE {
if (text_found > 0) {
nfiles_out++
close(FILENAME)
for (i=1;... | 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 AWK implementation. |
BEGIN {
old_text = "Goodbye London!"
new_text = "Hello New York!"
}
BEGINFILE {
nfiles_in++
text_found = 0
delete arr
}
{ if (gsub(old_text,new_text,$0) > 0) {
text_found++
}
arr[FNR] = $0
}
ENDFILE {
if (text_found > 0) {
nfiles_out++
close(FILENAME)
for (i=1;... | 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!", "... |
Change the programming language of this snippet from AWK to C++ without modifying what it does. |
BEGIN {
old_text = "Goodbye London!"
new_text = "Hello New York!"
}
BEGINFILE {
nfiles_in++
text_found = 0
delete arr
}
{ if (gsub(old_text,new_text,$0) > 0) {
text_found++
}
arr[FNR] = $0
}
ENDFILE {
if (text_found > 0) {
nfiles_out++
close(FILENAME)
for (i=1;... | #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 AWK code into C++ while preserving the original functionality. |
BEGIN {
old_text = "Goodbye London!"
new_text = "Hello New York!"
}
BEGINFILE {
nfiles_in++
text_found = 0
delete arr
}
{ if (gsub(old_text,new_text,$0) > 0) {
text_found++
}
arr[FNR] = $0
}
ENDFILE {
if (text_found > 0) {
nfiles_out++
close(FILENAME)
for (i=1;... | #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 AWK function in Java with identical behavior. |
BEGIN {
old_text = "Goodbye London!"
new_text = "Hello New York!"
}
BEGINFILE {
nfiles_in++
text_found = 0
delete arr
}
{ if (gsub(old_text,new_text,$0) > 0) {
text_found++
}
arr[FNR] = $0
}
ENDFILE {
if (text_found > 0) {
nfiles_out++
close(FILENAME)
for (i=1;... | 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 AWK block to Java, preserving its control flow and logic. |
BEGIN {
old_text = "Goodbye London!"
new_text = "Hello New York!"
}
BEGINFILE {
nfiles_in++
text_found = 0
delete arr
}
{ if (gsub(old_text,new_text,$0) > 0) {
text_found++
}
arr[FNR] = $0
}
ENDFILE {
if (text_found > 0) {
nfiles_out++
close(FILENAME)
for (i=1;... | 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 AWK code into Python without altering its purpose. |
BEGIN {
old_text = "Goodbye London!"
new_text = "Hello New York!"
}
BEGINFILE {
nfiles_in++
text_found = 0
delete arr
}
{ if (gsub(old_text,new_text,$0) > 0) {
text_found++
}
arr[FNR] = $0
}
ENDFILE {
if (text_found > 0) {
nfiles_out++
close(FILENAME)
for (i=1;... | import fileinput
for line in fileinput.input(inplace=True):
print(line.replace('Goodbye London!', 'Hello New York!'), end='')
|
Translate the given AWK code snippet into Python without altering its behavior. |
BEGIN {
old_text = "Goodbye London!"
new_text = "Hello New York!"
}
BEGINFILE {
nfiles_in++
text_found = 0
delete arr
}
{ if (gsub(old_text,new_text,$0) > 0) {
text_found++
}
arr[FNR] = $0
}
ENDFILE {
if (text_found > 0) {
nfiles_out++
close(FILENAME)
for (i=1;... | import fileinput
for line in fileinput.input(inplace=True):
print(line.replace('Goodbye London!', 'Hello New York!'), end='')
|
Rewrite the snippet below in Go so it works the same as the original AWK code. |
BEGIN {
old_text = "Goodbye London!"
new_text = "Hello New York!"
}
BEGINFILE {
nfiles_in++
text_found = 0
delete arr
}
{ if (gsub(old_text,new_text,$0) > 0) {
text_found++
}
arr[FNR] = $0
}
ENDFILE {
if (text_found > 0) {
nfiles_out++
close(FILENAME)
for (i=1;... | 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 AWK to Go, ensuring the logic remains intact. |
BEGIN {
old_text = "Goodbye London!"
new_text = "Hello New York!"
}
BEGINFILE {
nfiles_in++
text_found = 0
delete arr
}
{ if (gsub(old_text,new_text,$0) > 0) {
text_found++
}
arr[FNR] = $0
}
ENDFILE {
if (text_found > 0) {
nfiles_out++
close(FILENAME)
for (i=1;... | 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 C. | FindThis$ = "Goodbye London!"
ReplaceWith$ = "Hello New York!"
DIM Files$(3)
Files$() = "C:\test1.txt", "C:\test2.txt", "C:\test3.txt", "C:\test4.txt"
FOR f% = 0 TO DIM(Files$(),1)
infile$ = Files$(f%)
infile% = OPENIN(infile$)
IF infile%=0 ERROR 100, ... | #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 BBC_Basic, keeping it the same logically? | FindThis$ = "Goodbye London!"
ReplaceWith$ = "Hello New York!"
DIM Files$(3)
Files$() = "C:\test1.txt", "C:\test2.txt", "C:\test3.txt", "C:\test4.txt"
FOR f% = 0 TO DIM(Files$(),1)
infile$ = Files$(f%)
infile% = OPENIN(infile$)
IF infile%=0 ERROR 100, ... | #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 the snippet below in C# so it works the same as the original BBC_Basic code. | FindThis$ = "Goodbye London!"
ReplaceWith$ = "Hello New York!"
DIM Files$(3)
Files$() = "C:\test1.txt", "C:\test2.txt", "C:\test3.txt", "C:\test4.txt"
FOR f% = 0 TO DIM(Files$(),1)
infile$ = Files$(f%)
infile% = OPENIN(infile$)
IF infile%=0 ERROR 100, ... | 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 this BBC_Basic snippet to C# and keep its semantics consistent. | FindThis$ = "Goodbye London!"
ReplaceWith$ = "Hello New York!"
DIM Files$(3)
Files$() = "C:\test1.txt", "C:\test2.txt", "C:\test3.txt", "C:\test4.txt"
FOR f% = 0 TO DIM(Files$(),1)
infile$ = Files$(f%)
infile% = OPENIN(infile$)
IF infile%=0 ERROR 100, ... | 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 code in C++ as shown below in BBC_Basic. | FindThis$ = "Goodbye London!"
ReplaceWith$ = "Hello New York!"
DIM Files$(3)
Files$() = "C:\test1.txt", "C:\test2.txt", "C:\test3.txt", "C:\test4.txt"
FOR f% = 0 TO DIM(Files$(),1)
infile$ = Files$(f%)
infile% = OPENIN(infile$)
IF infile%=0 ERROR 100, ... | #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 an equivalent C++ version of this BBC_Basic code. | FindThis$ = "Goodbye London!"
ReplaceWith$ = "Hello New York!"
DIM Files$(3)
Files$() = "C:\test1.txt", "C:\test2.txt", "C:\test3.txt", "C:\test4.txt"
FOR f% = 0 TO DIM(Files$(),1)
infile$ = Files$(f%)
infile% = OPENIN(infile$)
IF infile%=0 ERROR 100, ... | #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 Java as shown below in BBC_Basic. | FindThis$ = "Goodbye London!"
ReplaceWith$ = "Hello New York!"
DIM Files$(3)
Files$() = "C:\test1.txt", "C:\test2.txt", "C:\test3.txt", "C:\test4.txt"
FOR f% = 0 TO DIM(Files$(),1)
infile$ = Files$(f%)
infile% = OPENIN(infile$)
IF infile%=0 ERROR 100, ... | 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 following code from BBC_Basic to Java with equivalent syntax and logic. | FindThis$ = "Goodbye London!"
ReplaceWith$ = "Hello New York!"
DIM Files$(3)
Files$() = "C:\test1.txt", "C:\test2.txt", "C:\test3.txt", "C:\test4.txt"
FOR f% = 0 TO DIM(Files$(),1)
infile$ = Files$(f%)
infile% = OPENIN(infile$)
IF infile%=0 ERROR 100, ... | 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 BBC_Basic version. | FindThis$ = "Goodbye London!"
ReplaceWith$ = "Hello New York!"
DIM Files$(3)
Files$() = "C:\test1.txt", "C:\test2.txt", "C:\test3.txt", "C:\test4.txt"
FOR f% = 0 TO DIM(Files$(),1)
infile$ = Files$(f%)
infile% = OPENIN(infile$)
IF infile%=0 ERROR 100, ... | import fileinput
for line in fileinput.input(inplace=True):
print(line.replace('Goodbye London!', 'Hello New York!'), end='')
|
Keep all operations the same but rewrite the snippet in Python. | FindThis$ = "Goodbye London!"
ReplaceWith$ = "Hello New York!"
DIM Files$(3)
Files$() = "C:\test1.txt", "C:\test2.txt", "C:\test3.txt", "C:\test4.txt"
FOR f% = 0 TO DIM(Files$(),1)
infile$ = Files$(f%)
infile% = OPENIN(infile$)
IF infile%=0 ERROR 100, ... | 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 Go. | FindThis$ = "Goodbye London!"
ReplaceWith$ = "Hello New York!"
DIM Files$(3)
Files$() = "C:\test1.txt", "C:\test2.txt", "C:\test3.txt", "C:\test4.txt"
FOR f% = 0 TO DIM(Files$(),1)
infile$ = Files$(f%)
infile% = OPENIN(infile$)
IF infile%=0 ERROR 100, ... | 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 BBC_Basic to Go. | FindThis$ = "Goodbye London!"
ReplaceWith$ = "Hello New York!"
DIM Files$(3)
Files$() = "C:\test1.txt", "C:\test2.txt", "C:\test3.txt", "C:\test4.txt"
FOR f% = 0 TO DIM(Files$(),1)
infile$ = Files$(f%)
infile% = OPENIN(infile$)
IF infile%=0 ERROR 100, ... | 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 Clojure. | (defn hello-goodbye [& more]
(doseq [file more]
(spit file (.replace (slurp file) "Goodbye London!" "Hello New York!"))))
| #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 Clojure to C, same semantics. | (defn hello-goodbye [& more]
(doseq [file more]
(spit file (.replace (slurp file) "Goodbye London!" "Hello New York!"))))
| #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 this program into C# but keep the logic exactly as in Clojure. | (defn hello-goodbye [& more]
(doseq [file more]
(spit file (.replace (slurp file) "Goodbye London!" "Hello New York!"))))
| 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 the given Clojure code snippet into C# without altering its behavior. | (defn hello-goodbye [& more]
(doseq [file more]
(spit file (.replace (slurp file) "Goodbye London!" "Hello New York!"))))
| 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 Clojure to C++, ensuring the logic remains intact. | (defn hello-goodbye [& more]
(doseq [file more]
(spit file (.replace (slurp file) "Goodbye London!" "Hello New York!"))))
| #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 Clojure code into C++ without altering its purpose. | (defn hello-goodbye [& more]
(doseq [file more]
(spit file (.replace (slurp file) "Goodbye London!" "Hello New York!"))))
| #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 Java as shown below in Clojure. | (defn hello-goodbye [& more]
(doseq [file more]
(spit file (.replace (slurp file) "Goodbye London!" "Hello New York!"))))
| 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 Clojure implementation. | (defn hello-goodbye [& more]
(doseq [file more]
(spit file (.replace (slurp file) "Goodbye London!" "Hello New York!"))))
| 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... |
Translate the given Clojure code snippet into Python without altering its behavior. | (defn hello-goodbye [& more]
(doseq [file more]
(spit file (.replace (slurp file) "Goodbye London!" "Hello New York!"))))
| import fileinput
for line in fileinput.input(inplace=True):
print(line.replace('Goodbye London!', 'Hello New York!'), end='')
|
Convert this Clojure block to Python, preserving its control flow and logic. | (defn hello-goodbye [& more]
(doseq [file more]
(spit file (.replace (slurp file) "Goodbye London!" "Hello New York!"))))
| import fileinput
for line in fileinput.input(inplace=True):
print(line.replace('Goodbye London!', 'Hello New York!'), end='')
|
Port the following code from Clojure to Go with equivalent syntax and logic. | (defn hello-goodbye [& more]
(doseq [file more]
(spit file (.replace (slurp file) "Goodbye London!" "Hello New York!"))))
| 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 Clojure to Go. | (defn hello-goodbye [& more]
(doseq [file more]
(spit file (.replace (slurp file) "Goodbye London!" "Hello New York!"))))
| 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 Common_Lisp to C. | (defun hello-goodbye (files)
(labels ((replace-from-file (file)
(with-open-file (in file)
(loop for line = (read-line in nil)
while line do
(loop for index = (search "Goodbye London!" line)
while index do
... | #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 Common_Lisp, keeping it the same logically? | (defun hello-goodbye (files)
(labels ((replace-from-file (file)
(with-open-file (in file)
(loop for line = (read-line in nil)
while line do
(loop for index = (search "Goodbye London!" line)
while index do
... | #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 Common_Lisp to C#, ensuring the logic remains intact. | (defun hello-goodbye (files)
(labels ((replace-from-file (file)
(with-open-file (in file)
(loop for line = (read-line in nil)
while line do
(loop for index = (search "Goodbye London!" line)
while index do
... | 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 a C# translation of this Common_Lisp snippet without changing its computational steps. | (defun hello-goodbye (files)
(labels ((replace-from-file (file)
(with-open-file (in file)
(loop for line = (read-line in nil)
while line do
(loop for index = (search "Goodbye London!" line)
while index do
... | 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!", "... |
Rewrite the snippet below in C++ so it works the same as the original Common_Lisp code. | (defun hello-goodbye (files)
(labels ((replace-from-file (file)
(with-open-file (in file)
(loop for line = (read-line in nil)
while line do
(loop for index = (search "Goodbye London!" line)
while index do
... | #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 Common_Lisp implementation into C++, maintaining the same output and logic. | (defun hello-goodbye (files)
(labels ((replace-from-file (file)
(with-open-file (in file)
(loop for line = (read-line in nil)
while line do
(loop for index = (search "Goodbye London!" line)
while index do
... | #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 (... |
Maintain the same structure and functionality when rewriting this code in Java. | (defun hello-goodbye (files)
(labels ((replace-from-file (file)
(with-open-file (in file)
(loop for line = (read-line in nil)
while line do
(loop for index = (search "Goodbye London!" line)
while index do
... | 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 code in Java as shown below in Common_Lisp. | (defun hello-goodbye (files)
(labels ((replace-from-file (file)
(with-open-file (in file)
(loop for line = (read-line in nil)
while line do
(loop for index = (search "Goodbye London!" line)
while index do
... | 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 Common_Lisp. | (defun hello-goodbye (files)
(labels ((replace-from-file (file)
(with-open-file (in file)
(loop for line = (read-line in nil)
while line do
(loop for index = (search "Goodbye London!" line)
while index do
... | import fileinput
for line in fileinput.input(inplace=True):
print(line.replace('Goodbye London!', 'Hello New York!'), end='')
|
Transform the following Common_Lisp implementation into Python, maintaining the same output and logic. | (defun hello-goodbye (files)
(labels ((replace-from-file (file)
(with-open-file (in file)
(loop for line = (read-line in nil)
while line do
(loop for index = (search "Goodbye London!" line)
while index do
... | import fileinput
for line in fileinput.input(inplace=True):
print(line.replace('Goodbye London!', 'Hello New York!'), end='')
|
Produce a functionally identical Go code for the snippet given in Common_Lisp. | (defun hello-goodbye (files)
(labels ((replace-from-file (file)
(with-open-file (in file)
(loop for line = (read-line in nil)
while line do
(loop for index = (search "Goodbye London!" line)
while index do
... | 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. | (defun hello-goodbye (files)
(labels ((replace-from-file (file)
(with-open-file (in file)
(loop for line = (read-line in nil)
while line do
(loop for index = (search "Goodbye London!" line)
while index do
... | 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 D to C, ensuring the logic remains intact. | import std.file, std.array;
void main() {
auto from = "Goodbye London!", to = "Hello, New York!";
foreach (fn; "a.txt b.txt c.txt".split()) {
write(fn, replace(cast(string)read(fn), from, to));
}
}
| #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 this program into C but keep the logic exactly as in D. | import std.file, std.array;
void main() {
auto from = "Goodbye London!", to = "Hello, New York!";
foreach (fn; "a.txt b.txt c.txt".split()) {
write(fn, replace(cast(string)read(fn), from, to));
}
}
| #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 D to C#, ensuring the logic remains intact. | import std.file, std.array;
void main() {
auto from = "Goodbye London!", to = "Hello, New York!";
foreach (fn; "a.txt b.txt c.txt".split()) {
write(fn, replace(cast(string)read(fn), from, to));
}
}
| 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 D to C#, ensuring the logic remains intact. | import std.file, std.array;
void main() {
auto from = "Goodbye London!", to = "Hello, New York!";
foreach (fn; "a.txt b.txt c.txt".split()) {
write(fn, replace(cast(string)read(fn), from, to));
}
}
| 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 D to C++. | import std.file, std.array;
void main() {
auto from = "Goodbye London!", to = "Hello, New York!";
foreach (fn; "a.txt b.txt c.txt".split()) {
write(fn, replace(cast(string)read(fn), from, to));
}
}
| #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 (... |
Rewrite the snippet below in C++ so it works the same as the original D code. | import std.file, std.array;
void main() {
auto from = "Goodbye London!", to = "Hello, New York!";
foreach (fn; "a.txt b.txt c.txt".split()) {
write(fn, replace(cast(string)read(fn), from, to));
}
}
| #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 D, keeping it the same logically? | import std.file, std.array;
void main() {
auto from = "Goodbye London!", to = "Hello, New York!";
foreach (fn; "a.txt b.txt c.txt".split()) {
write(fn, replace(cast(string)read(fn), from, to));
}
}
| 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 D block to Java, preserving its control flow and logic. | import std.file, std.array;
void main() {
auto from = "Goodbye London!", to = "Hello, New York!";
foreach (fn; "a.txt b.txt c.txt".split()) {
write(fn, replace(cast(string)read(fn), from, to));
}
}
| 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 D block to Python, preserving its control flow and logic. | import std.file, std.array;
void main() {
auto from = "Goodbye London!", to = "Hello, New York!";
foreach (fn; "a.txt b.txt c.txt".split()) {
write(fn, replace(cast(string)read(fn), from, to));
}
}
| import fileinput
for line in fileinput.input(inplace=True):
print(line.replace('Goodbye London!', 'Hello New York!'), end='')
|
Write the same code in Python as shown below in D. | import std.file, std.array;
void main() {
auto from = "Goodbye London!", to = "Hello, New York!";
foreach (fn; "a.txt b.txt c.txt".split()) {
write(fn, replace(cast(string)read(fn), from, to));
}
}
| import fileinput
for line in fileinput.input(inplace=True):
print(line.replace('Goodbye London!', 'Hello New York!'), end='')
|
Rewrite this program in Go while keeping its functionality equivalent to the D version. | import std.file, std.array;
void main() {
auto from = "Goodbye London!", to = "Hello, New York!";
foreach (fn; "a.txt b.txt c.txt".split()) {
write(fn, replace(cast(string)read(fn), from, to));
}
}
| 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 Go but keep the logic exactly as in D. | import std.file, std.array;
void main() {
auto from = "Goodbye London!", to = "Hello, New York!";
foreach (fn; "a.txt b.txt c.txt".split()) {
write(fn, replace(cast(string)read(fn), from, to));
}
}
| 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 Delphi code into C while preserving the original functionality. | program Globally_replace_text_in_several_files;
uses
System.SysUtils,
System.IoUtils;
procedure StringReplaceByFile(_old, _new: string; FileName: TFilename;
ReplaceFlags: TReplaceFlags = []); overload
var
Text: string;
begin
if not FileExists(FileName) then
exit;
Text := TFile.ReadAllText(FileName);... | #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 Delphi snippet without changing its computational steps. | program Globally_replace_text_in_several_files;
uses
System.SysUtils,
System.IoUtils;
procedure StringReplaceByFile(_old, _new: string; FileName: TFilename;
ReplaceFlags: TReplaceFlags = []); overload
var
Text: string;
begin
if not FileExists(FileName) then
exit;
Text := TFile.ReadAllText(FileName);... | #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 Delphi to C# with equivalent syntax and logic. | program Globally_replace_text_in_several_files;
uses
System.SysUtils,
System.IoUtils;
procedure StringReplaceByFile(_old, _new: string; FileName: TFilename;
ReplaceFlags: TReplaceFlags = []); overload
var
Text: string;
begin
if not FileExists(FileName) then
exit;
Text := TFile.ReadAllText(FileName);... | 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 Delphi code. | program Globally_replace_text_in_several_files;
uses
System.SysUtils,
System.IoUtils;
procedure StringReplaceByFile(_old, _new: string; FileName: TFilename;
ReplaceFlags: TReplaceFlags = []); overload
var
Text: string;
begin
if not FileExists(FileName) then
exit;
Text := TFile.ReadAllText(FileName);... | 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 Delphi function in C++ with identical behavior. | program Globally_replace_text_in_several_files;
uses
System.SysUtils,
System.IoUtils;
procedure StringReplaceByFile(_old, _new: string; FileName: TFilename;
ReplaceFlags: TReplaceFlags = []); overload
var
Text: string;
begin
if not FileExists(FileName) then
exit;
Text := TFile.ReadAllText(FileName);... | #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 Delphi code into C++ without altering its purpose. | program Globally_replace_text_in_several_files;
uses
System.SysUtils,
System.IoUtils;
procedure StringReplaceByFile(_old, _new: string; FileName: TFilename;
ReplaceFlags: TReplaceFlags = []); overload
var
Text: string;
begin
if not FileExists(FileName) then
exit;
Text := TFile.ReadAllText(FileName);... | #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 Delphi snippet to Java and keep its semantics consistent. | program Globally_replace_text_in_several_files;
uses
System.SysUtils,
System.IoUtils;
procedure StringReplaceByFile(_old, _new: string; FileName: TFilename;
ReplaceFlags: TReplaceFlags = []); overload
var
Text: string;
begin
if not FileExists(FileName) then
exit;
Text := TFile.ReadAllText(FileName);... | 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 the following code from Delphi to Java, ensuring the logic remains intact. | program Globally_replace_text_in_several_files;
uses
System.SysUtils,
System.IoUtils;
procedure StringReplaceByFile(_old, _new: string; FileName: TFilename;
ReplaceFlags: TReplaceFlags = []); overload
var
Text: string;
begin
if not FileExists(FileName) then
exit;
Text := TFile.ReadAllText(FileName);... | 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 Delphi function in Python with identical behavior. | program Globally_replace_text_in_several_files;
uses
System.SysUtils,
System.IoUtils;
procedure StringReplaceByFile(_old, _new: string; FileName: TFilename;
ReplaceFlags: TReplaceFlags = []); overload
var
Text: string;
begin
if not FileExists(FileName) then
exit;
Text := TFile.ReadAllText(FileName);... | 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. | program Globally_replace_text_in_several_files;
uses
System.SysUtils,
System.IoUtils;
procedure StringReplaceByFile(_old, _new: string; FileName: TFilename;
ReplaceFlags: TReplaceFlags = []); overload
var
Text: string;
begin
if not FileExists(FileName) then
exit;
Text := TFile.ReadAllText(FileName);... | import fileinput
for line in fileinput.input(inplace=True):
print(line.replace('Goodbye London!', 'Hello New York!'), end='')
|
Transform the following Delphi implementation into Go, maintaining the same output and logic. | program Globally_replace_text_in_several_files;
uses
System.SysUtils,
System.IoUtils;
procedure StringReplaceByFile(_old, _new: string; FileName: TFilename;
ReplaceFlags: TReplaceFlags = []); overload
var
Text: string;
begin
if not FileExists(FileName) then
exit;
Text := TFile.ReadAllText(FileName);... | 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... |
Please provide an equivalent version of this Delphi code in Go. | program Globally_replace_text_in_several_files;
uses
System.SysUtils,
System.IoUtils;
procedure StringReplaceByFile(_old, _new: string; FileName: TFilename;
ReplaceFlags: TReplaceFlags = []); overload
var
Text: string;
begin
if not FileExists(FileName) then
exit;
Text := TFile.ReadAllText(FileName);... | 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... |
Produce a functionally identical C code for the snippet given in Erlang. | -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] ) -... | #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... |
Transform the following Erlang implementation into C, maintaining the same output and logic. | -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] ) -... | #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 Erlang, keeping it the same logically? | -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] ) -... | 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 this Erlang block to C#, preserving its control flow and logic. | -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] ) -... | 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 Erlang. | -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] ) -... | #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 Erlang to C++, 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] ) -... | #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 (... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.