Instruction stringlengths 45 106 | input_code stringlengths 1 13.7k | output_code stringlengths 1 13.7k |
|---|---|---|
Port the following code from AWK to Java with equivalent syntax and logic. | BEGIN {
printf "" > "output.txt"
close("output.txt")
printf "" > "/output.txt"
close("/output.txt")
system("mkdir docs")
system("mkdir /docs")
}
| import java.io.*;
public class CreateFileTest {
public static void main(String args[]) {
try {
new File("output.txt").createNewFile();
new File(File.separator + "output.txt").createNewFile();
new File("docs").mkdir();
new File(File.separator + "docs").mkdir();
} catch (IOException e) {
System.err.println(e.getMessage());
}
}
}
|
Maintain the same structure and functionality when rewriting this code in Python. | BEGIN {
printf "" > "output.txt"
close("output.txt")
printf "" > "/output.txt"
close("/output.txt")
system("mkdir docs")
system("mkdir /docs")
}
| import os
for directory in ['/', './']:
open(directory + 'output.txt', 'w').close()
os.mkdir(directory + 'docs')
|
Rewrite this program in VB while keeping its functionality equivalent to the AWK version. | BEGIN {
printf "" > "output.txt"
close("output.txt")
printf "" > "/output.txt"
close("/output.txt")
system("mkdir docs")
system("mkdir /docs")
}
| Public Sub create_file()
Dim FileNumber As Integer
FileNumber = FreeFile
MkDir "docs"
Open "docs\output.txt" For Output As #FreeFile
Close #FreeFile
MkDir "C:\docs"
Open "C:\docs\output.txt" For Output As #FreeFile
Close #FreeFile
End Sub
|
Preserve the algorithm and functionality while converting the code from AWK to Go. | BEGIN {
printf "" > "output.txt"
close("output.txt")
printf "" > "/output.txt"
close("/output.txt")
system("mkdir docs")
system("mkdir /docs")
}
| package main
import (
"fmt"
"os"
)
func createFile(fn string) {
f, err := os.Create(fn)
if err != nil {
fmt.Println(err)
return
}
fmt.Println("file", fn, "created!")
f.Close()
}
func createDir(dn string) {
err := os.Mkdir(dn, 0666)
if err != nil {
fmt.Println(err)
return
}
fmt.Println("directory", dn, "created!")
}
func main() {
createFile("input.txt")
createFile("/input.txt")
createDir("docs")
createDir("/docs")
}
|
Produce a language-to-language conversion: from BBC_Basic to C, same semantics. | CLOSE #OPENOUT("output.txt")
CLOSE #OPENOUT("\output.txt")
*MKDIR docs
*MKDIR \docs
| #include <stdio.h>
int main() {
FILE *fh = fopen("output.txt", "w");
fclose(fh);
return 0;
}
|
Produce a language-to-language conversion: from BBC_Basic to C#, same semantics. | CLOSE #OPENOUT("output.txt")
CLOSE #OPENOUT("\output.txt")
*MKDIR docs
*MKDIR \docs
| using System;
using System.IO;
class Program {
static void Main(string[] args) {
File.Create("output.txt");
File.Create(@"\output.txt");
Directory.CreateDirectory("docs");
Directory.CreateDirectory(@"\docs");
}
}
|
Generate an equivalent C++ version of this BBC_Basic code. | CLOSE #OPENOUT("output.txt")
CLOSE #OPENOUT("\output.txt")
*MKDIR docs
*MKDIR \docs
| #include <direct.h>
#include <fstream>
int main() {
std::fstream f("output.txt", std::ios::out);
f.close();
f.open("/output.txt", std::ios::out);
f.close();
_mkdir("docs");
_mkdir("/docs");
return 0;
}
|
Ensure the translated Java code behaves exactly like the original BBC_Basic snippet. | CLOSE #OPENOUT("output.txt")
CLOSE #OPENOUT("\output.txt")
*MKDIR docs
*MKDIR \docs
| import java.io.*;
public class CreateFileTest {
public static void main(String args[]) {
try {
new File("output.txt").createNewFile();
new File(File.separator + "output.txt").createNewFile();
new File("docs").mkdir();
new File(File.separator + "docs").mkdir();
} catch (IOException e) {
System.err.println(e.getMessage());
}
}
}
|
Convert the following code from BBC_Basic to Python, ensuring the logic remains intact. | CLOSE #OPENOUT("output.txt")
CLOSE #OPENOUT("\output.txt")
*MKDIR docs
*MKDIR \docs
| import os
for directory in ['/', './']:
open(directory + 'output.txt', 'w').close()
os.mkdir(directory + 'docs')
|
Generate a VB translation of this BBC_Basic snippet without changing its computational steps. | CLOSE #OPENOUT("output.txt")
CLOSE #OPENOUT("\output.txt")
*MKDIR docs
*MKDIR \docs
| Public Sub create_file()
Dim FileNumber As Integer
FileNumber = FreeFile
MkDir "docs"
Open "docs\output.txt" For Output As #FreeFile
Close #FreeFile
MkDir "C:\docs"
Open "C:\docs\output.txt" For Output As #FreeFile
Close #FreeFile
End Sub
|
Convert the following code from BBC_Basic to Go, ensuring the logic remains intact. | CLOSE #OPENOUT("output.txt")
CLOSE #OPENOUT("\output.txt")
*MKDIR docs
*MKDIR \docs
| package main
import (
"fmt"
"os"
)
func createFile(fn string) {
f, err := os.Create(fn)
if err != nil {
fmt.Println(err)
return
}
fmt.Println("file", fn, "created!")
f.Close()
}
func createDir(dn string) {
err := os.Mkdir(dn, 0666)
if err != nil {
fmt.Println(err)
return
}
fmt.Println("directory", dn, "created!")
}
func main() {
createFile("input.txt")
createFile("/input.txt")
createDir("docs")
createDir("/docs")
}
|
Produce a functionally identical C code for the snippet given in Common_Lisp. | (import '(java.io File))
(.createNewFile (new File "output.txt"))
(.mkdir (new File "docs"))
(.createNewFile (File. (str (File/separator) "output.txt")))
(.mkdir (File. (str (File/separator) "docs")))
| #include <stdio.h>
int main() {
FILE *fh = fopen("output.txt", "w");
fclose(fh);
return 0;
}
|
Translate the given Common_Lisp code snippet into C# without altering its behavior. | (import '(java.io File))
(.createNewFile (new File "output.txt"))
(.mkdir (new File "docs"))
(.createNewFile (File. (str (File/separator) "output.txt")))
(.mkdir (File. (str (File/separator) "docs")))
| using System;
using System.IO;
class Program {
static void Main(string[] args) {
File.Create("output.txt");
File.Create(@"\output.txt");
Directory.CreateDirectory("docs");
Directory.CreateDirectory(@"\docs");
}
}
|
Port the provided Common_Lisp code into C++ while preserving the original functionality. | (import '(java.io File))
(.createNewFile (new File "output.txt"))
(.mkdir (new File "docs"))
(.createNewFile (File. (str (File/separator) "output.txt")))
(.mkdir (File. (str (File/separator) "docs")))
| #include <direct.h>
#include <fstream>
int main() {
std::fstream f("output.txt", std::ios::out);
f.close();
f.open("/output.txt", std::ios::out);
f.close();
_mkdir("docs");
_mkdir("/docs");
return 0;
}
|
Rewrite the snippet below in Java so it works the same as the original Common_Lisp code. | (import '(java.io File))
(.createNewFile (new File "output.txt"))
(.mkdir (new File "docs"))
(.createNewFile (File. (str (File/separator) "output.txt")))
(.mkdir (File. (str (File/separator) "docs")))
| import java.io.*;
public class CreateFileTest {
public static void main(String args[]) {
try {
new File("output.txt").createNewFile();
new File(File.separator + "output.txt").createNewFile();
new File("docs").mkdir();
new File(File.separator + "docs").mkdir();
} catch (IOException e) {
System.err.println(e.getMessage());
}
}
}
|
Port the provided Common_Lisp code into Python while preserving the original functionality. | (import '(java.io File))
(.createNewFile (new File "output.txt"))
(.mkdir (new File "docs"))
(.createNewFile (File. (str (File/separator) "output.txt")))
(.mkdir (File. (str (File/separator) "docs")))
| import os
for directory in ['/', './']:
open(directory + 'output.txt', 'w').close()
os.mkdir(directory + 'docs')
|
Keep all operations the same but rewrite the snippet in VB. | (import '(java.io File))
(.createNewFile (new File "output.txt"))
(.mkdir (new File "docs"))
(.createNewFile (File. (str (File/separator) "output.txt")))
(.mkdir (File. (str (File/separator) "docs")))
| Public Sub create_file()
Dim FileNumber As Integer
FileNumber = FreeFile
MkDir "docs"
Open "docs\output.txt" For Output As #FreeFile
Close #FreeFile
MkDir "C:\docs"
Open "C:\docs\output.txt" For Output As #FreeFile
Close #FreeFile
End Sub
|
Translate the given Common_Lisp code snippet into Go without altering its behavior. | (import '(java.io File))
(.createNewFile (new File "output.txt"))
(.mkdir (new File "docs"))
(.createNewFile (File. (str (File/separator) "output.txt")))
(.mkdir (File. (str (File/separator) "docs")))
| package main
import (
"fmt"
"os"
)
func createFile(fn string) {
f, err := os.Create(fn)
if err != nil {
fmt.Println(err)
return
}
fmt.Println("file", fn, "created!")
f.Close()
}
func createDir(dn string) {
err := os.Mkdir(dn, 0666)
if err != nil {
fmt.Println(err)
return
}
fmt.Println("directory", dn, "created!")
}
func main() {
createFile("input.txt")
createFile("/input.txt")
createDir("docs")
createDir("/docs")
}
|
Convert the following code from D to C, ensuring the logic remains intact. | module fileio ;
import std.stdio ;
import std.path ;
import std.file ;
import std.stream ;
string[] genName(string name){
string cwd = curdir ~ sep ;
string root = sep ;
name = std.path.getBaseName(name) ;
return [cwd ~ name, root ~ name] ;
}
void Remove(string target){
if(exists(target)){
if (isfile(target))
std.file.remove(target);
else
std.file.rmdir(target) ;
}
}
void testCreate(string filename, string dirname){
foreach(fn ; genName(filename))
try{
writefln("file to be created : %s", fn) ;
std.file.write(fn, cast(void[])null) ;
writefln("\tsuccess by std.file.write") ; Remove(fn) ;
(new std.stream.File(fn, FileMode.OutNew)).close() ;
writefln("\tsuccess by std.stream") ; Remove(fn) ;
} catch(Exception e) {
writefln(e.msg) ;
}
foreach(dn ; genName(dirname))
try{
writefln("dir to be created : %s", dn) ;
std.file.mkdir(dn) ;
writefln("\tsuccess by std.file.mkdir") ; Remove(dn) ;
} catch(Exception e) {
writefln(e.msg) ;
}
}
void main(){
writefln("== test: File & Dir Creation ==") ;
testCreate("output.txt", "docs") ;
}
| #include <stdio.h>
int main() {
FILE *fh = fopen("output.txt", "w");
fclose(fh);
return 0;
}
|
Write the same algorithm in C# as shown in this D implementation. | module fileio ;
import std.stdio ;
import std.path ;
import std.file ;
import std.stream ;
string[] genName(string name){
string cwd = curdir ~ sep ;
string root = sep ;
name = std.path.getBaseName(name) ;
return [cwd ~ name, root ~ name] ;
}
void Remove(string target){
if(exists(target)){
if (isfile(target))
std.file.remove(target);
else
std.file.rmdir(target) ;
}
}
void testCreate(string filename, string dirname){
foreach(fn ; genName(filename))
try{
writefln("file to be created : %s", fn) ;
std.file.write(fn, cast(void[])null) ;
writefln("\tsuccess by std.file.write") ; Remove(fn) ;
(new std.stream.File(fn, FileMode.OutNew)).close() ;
writefln("\tsuccess by std.stream") ; Remove(fn) ;
} catch(Exception e) {
writefln(e.msg) ;
}
foreach(dn ; genName(dirname))
try{
writefln("dir to be created : %s", dn) ;
std.file.mkdir(dn) ;
writefln("\tsuccess by std.file.mkdir") ; Remove(dn) ;
} catch(Exception e) {
writefln(e.msg) ;
}
}
void main(){
writefln("== test: File & Dir Creation ==") ;
testCreate("output.txt", "docs") ;
}
| using System;
using System.IO;
class Program {
static void Main(string[] args) {
File.Create("output.txt");
File.Create(@"\output.txt");
Directory.CreateDirectory("docs");
Directory.CreateDirectory(@"\docs");
}
}
|
Rewrite this program in C++ while keeping its functionality equivalent to the D version. | module fileio ;
import std.stdio ;
import std.path ;
import std.file ;
import std.stream ;
string[] genName(string name){
string cwd = curdir ~ sep ;
string root = sep ;
name = std.path.getBaseName(name) ;
return [cwd ~ name, root ~ name] ;
}
void Remove(string target){
if(exists(target)){
if (isfile(target))
std.file.remove(target);
else
std.file.rmdir(target) ;
}
}
void testCreate(string filename, string dirname){
foreach(fn ; genName(filename))
try{
writefln("file to be created : %s", fn) ;
std.file.write(fn, cast(void[])null) ;
writefln("\tsuccess by std.file.write") ; Remove(fn) ;
(new std.stream.File(fn, FileMode.OutNew)).close() ;
writefln("\tsuccess by std.stream") ; Remove(fn) ;
} catch(Exception e) {
writefln(e.msg) ;
}
foreach(dn ; genName(dirname))
try{
writefln("dir to be created : %s", dn) ;
std.file.mkdir(dn) ;
writefln("\tsuccess by std.file.mkdir") ; Remove(dn) ;
} catch(Exception e) {
writefln(e.msg) ;
}
}
void main(){
writefln("== test: File & Dir Creation ==") ;
testCreate("output.txt", "docs") ;
}
| #include <direct.h>
#include <fstream>
int main() {
std::fstream f("output.txt", std::ios::out);
f.close();
f.open("/output.txt", std::ios::out);
f.close();
_mkdir("docs");
_mkdir("/docs");
return 0;
}
|
Keep all operations the same but rewrite the snippet in Java. | module fileio ;
import std.stdio ;
import std.path ;
import std.file ;
import std.stream ;
string[] genName(string name){
string cwd = curdir ~ sep ;
string root = sep ;
name = std.path.getBaseName(name) ;
return [cwd ~ name, root ~ name] ;
}
void Remove(string target){
if(exists(target)){
if (isfile(target))
std.file.remove(target);
else
std.file.rmdir(target) ;
}
}
void testCreate(string filename, string dirname){
foreach(fn ; genName(filename))
try{
writefln("file to be created : %s", fn) ;
std.file.write(fn, cast(void[])null) ;
writefln("\tsuccess by std.file.write") ; Remove(fn) ;
(new std.stream.File(fn, FileMode.OutNew)).close() ;
writefln("\tsuccess by std.stream") ; Remove(fn) ;
} catch(Exception e) {
writefln(e.msg) ;
}
foreach(dn ; genName(dirname))
try{
writefln("dir to be created : %s", dn) ;
std.file.mkdir(dn) ;
writefln("\tsuccess by std.file.mkdir") ; Remove(dn) ;
} catch(Exception e) {
writefln(e.msg) ;
}
}
void main(){
writefln("== test: File & Dir Creation ==") ;
testCreate("output.txt", "docs") ;
}
| import java.io.*;
public class CreateFileTest {
public static void main(String args[]) {
try {
new File("output.txt").createNewFile();
new File(File.separator + "output.txt").createNewFile();
new File("docs").mkdir();
new File(File.separator + "docs").mkdir();
} catch (IOException e) {
System.err.println(e.getMessage());
}
}
}
|
Rewrite the snippet below in Python so it works the same as the original D code. | module fileio ;
import std.stdio ;
import std.path ;
import std.file ;
import std.stream ;
string[] genName(string name){
string cwd = curdir ~ sep ;
string root = sep ;
name = std.path.getBaseName(name) ;
return [cwd ~ name, root ~ name] ;
}
void Remove(string target){
if(exists(target)){
if (isfile(target))
std.file.remove(target);
else
std.file.rmdir(target) ;
}
}
void testCreate(string filename, string dirname){
foreach(fn ; genName(filename))
try{
writefln("file to be created : %s", fn) ;
std.file.write(fn, cast(void[])null) ;
writefln("\tsuccess by std.file.write") ; Remove(fn) ;
(new std.stream.File(fn, FileMode.OutNew)).close() ;
writefln("\tsuccess by std.stream") ; Remove(fn) ;
} catch(Exception e) {
writefln(e.msg) ;
}
foreach(dn ; genName(dirname))
try{
writefln("dir to be created : %s", dn) ;
std.file.mkdir(dn) ;
writefln("\tsuccess by std.file.mkdir") ; Remove(dn) ;
} catch(Exception e) {
writefln(e.msg) ;
}
}
void main(){
writefln("== test: File & Dir Creation ==") ;
testCreate("output.txt", "docs") ;
}
| import os
for directory in ['/', './']:
open(directory + 'output.txt', 'w').close()
os.mkdir(directory + 'docs')
|
Transform the following D implementation into VB, maintaining the same output and logic. | module fileio ;
import std.stdio ;
import std.path ;
import std.file ;
import std.stream ;
string[] genName(string name){
string cwd = curdir ~ sep ;
string root = sep ;
name = std.path.getBaseName(name) ;
return [cwd ~ name, root ~ name] ;
}
void Remove(string target){
if(exists(target)){
if (isfile(target))
std.file.remove(target);
else
std.file.rmdir(target) ;
}
}
void testCreate(string filename, string dirname){
foreach(fn ; genName(filename))
try{
writefln("file to be created : %s", fn) ;
std.file.write(fn, cast(void[])null) ;
writefln("\tsuccess by std.file.write") ; Remove(fn) ;
(new std.stream.File(fn, FileMode.OutNew)).close() ;
writefln("\tsuccess by std.stream") ; Remove(fn) ;
} catch(Exception e) {
writefln(e.msg) ;
}
foreach(dn ; genName(dirname))
try{
writefln("dir to be created : %s", dn) ;
std.file.mkdir(dn) ;
writefln("\tsuccess by std.file.mkdir") ; Remove(dn) ;
} catch(Exception e) {
writefln(e.msg) ;
}
}
void main(){
writefln("== test: File & Dir Creation ==") ;
testCreate("output.txt", "docs") ;
}
| Public Sub create_file()
Dim FileNumber As Integer
FileNumber = FreeFile
MkDir "docs"
Open "docs\output.txt" For Output As #FreeFile
Close #FreeFile
MkDir "C:\docs"
Open "C:\docs\output.txt" For Output As #FreeFile
Close #FreeFile
End Sub
|
Change the following D code into Go without altering its purpose. | module fileio ;
import std.stdio ;
import std.path ;
import std.file ;
import std.stream ;
string[] genName(string name){
string cwd = curdir ~ sep ;
string root = sep ;
name = std.path.getBaseName(name) ;
return [cwd ~ name, root ~ name] ;
}
void Remove(string target){
if(exists(target)){
if (isfile(target))
std.file.remove(target);
else
std.file.rmdir(target) ;
}
}
void testCreate(string filename, string dirname){
foreach(fn ; genName(filename))
try{
writefln("file to be created : %s", fn) ;
std.file.write(fn, cast(void[])null) ;
writefln("\tsuccess by std.file.write") ; Remove(fn) ;
(new std.stream.File(fn, FileMode.OutNew)).close() ;
writefln("\tsuccess by std.stream") ; Remove(fn) ;
} catch(Exception e) {
writefln(e.msg) ;
}
foreach(dn ; genName(dirname))
try{
writefln("dir to be created : %s", dn) ;
std.file.mkdir(dn) ;
writefln("\tsuccess by std.file.mkdir") ; Remove(dn) ;
} catch(Exception e) {
writefln(e.msg) ;
}
}
void main(){
writefln("== test: File & Dir Creation ==") ;
testCreate("output.txt", "docs") ;
}
| package main
import (
"fmt"
"os"
)
func createFile(fn string) {
f, err := os.Create(fn)
if err != nil {
fmt.Println(err)
return
}
fmt.Println("file", fn, "created!")
f.Close()
}
func createDir(dn string) {
err := os.Mkdir(dn, 0666)
if err != nil {
fmt.Println(err)
return
}
fmt.Println("directory", dn, "created!")
}
func main() {
createFile("input.txt")
createFile("/input.txt")
createDir("docs")
createDir("/docs")
}
|
Maintain the same structure and functionality when rewriting this code in C. | program createFile;
uses
Classes,
SysUtils;
const
filename = 'output.txt';
var
cwdPath,
fsPath: string;
function CreateEmptyFile1: Boolean;
var
f: textfile;
begin
cwdPath := ExtractFilePath(ParamStr(0)) + '1_'+filename;
AssignFile(f,cwdPath);
Rewrite(f);
Result := IOResult = 0;
CloseFile(f);
end;
function CreateEmptyFile2: Boolean;
var
f: textfile;
begin
fsPath := ExtractFileDrive(ParamStr(0)) + '\' + '2_'+filename;
AssignFile(f,fsPath);
Rewrite(f);
Result := IOResult = 0;
CloseFile(f);
end;
function CreateEmptyFile3: Boolean;
var
fs: TFileStream;
begin
cwdPath := ExtractFilePath(ParamStr(0)) + '3_'+filename;
fs := TFileStream.Create(cwdPath,fmCreate);
fs.Free;
Result := FileExists(cwdPath);
end;
function CreateEmptyFile4: Boolean;
var
fs: TFileStream;
begin
fsPath := ExtractFileDrive(ParamStr(0)) + '\' + '4_'+filename;
fs := TFileStream.Create(fsPath,fmCreate);
fs.Free;
Result := FileExists(fsPath);
end;
begin
if CreateEmptyFile1 then
Writeln('File created at '+cwdPath)
else
Writeln('Error creating file at '+cwdPath);
if CreateEmptyFile2 then
Writeln('File created at '+fsPath)
else
Writeln('Error creating file at '+fsPath);
if CreateEmptyFile3 then
Writeln('File created at '+cwdPath)
else
Writeln('Error creating file at '+cwdPath);
if CreateEmptyFile4 then
Writeln('File created at '+fsPath)
else
Writeln('Error creating file at '+fsPath);
Readln;
end.
| #include <stdio.h>
int main() {
FILE *fh = fopen("output.txt", "w");
fclose(fh);
return 0;
}
|
Transform the following Delphi implementation into C#, maintaining the same output and logic. | program createFile;
uses
Classes,
SysUtils;
const
filename = 'output.txt';
var
cwdPath,
fsPath: string;
function CreateEmptyFile1: Boolean;
var
f: textfile;
begin
cwdPath := ExtractFilePath(ParamStr(0)) + '1_'+filename;
AssignFile(f,cwdPath);
Rewrite(f);
Result := IOResult = 0;
CloseFile(f);
end;
function CreateEmptyFile2: Boolean;
var
f: textfile;
begin
fsPath := ExtractFileDrive(ParamStr(0)) + '\' + '2_'+filename;
AssignFile(f,fsPath);
Rewrite(f);
Result := IOResult = 0;
CloseFile(f);
end;
function CreateEmptyFile3: Boolean;
var
fs: TFileStream;
begin
cwdPath := ExtractFilePath(ParamStr(0)) + '3_'+filename;
fs := TFileStream.Create(cwdPath,fmCreate);
fs.Free;
Result := FileExists(cwdPath);
end;
function CreateEmptyFile4: Boolean;
var
fs: TFileStream;
begin
fsPath := ExtractFileDrive(ParamStr(0)) + '\' + '4_'+filename;
fs := TFileStream.Create(fsPath,fmCreate);
fs.Free;
Result := FileExists(fsPath);
end;
begin
if CreateEmptyFile1 then
Writeln('File created at '+cwdPath)
else
Writeln('Error creating file at '+cwdPath);
if CreateEmptyFile2 then
Writeln('File created at '+fsPath)
else
Writeln('Error creating file at '+fsPath);
if CreateEmptyFile3 then
Writeln('File created at '+cwdPath)
else
Writeln('Error creating file at '+cwdPath);
if CreateEmptyFile4 then
Writeln('File created at '+fsPath)
else
Writeln('Error creating file at '+fsPath);
Readln;
end.
| using System;
using System.IO;
class Program {
static void Main(string[] args) {
File.Create("output.txt");
File.Create(@"\output.txt");
Directory.CreateDirectory("docs");
Directory.CreateDirectory(@"\docs");
}
}
|
Change the programming language of this snippet from Delphi to C++ without modifying what it does. | program createFile;
uses
Classes,
SysUtils;
const
filename = 'output.txt';
var
cwdPath,
fsPath: string;
function CreateEmptyFile1: Boolean;
var
f: textfile;
begin
cwdPath := ExtractFilePath(ParamStr(0)) + '1_'+filename;
AssignFile(f,cwdPath);
Rewrite(f);
Result := IOResult = 0;
CloseFile(f);
end;
function CreateEmptyFile2: Boolean;
var
f: textfile;
begin
fsPath := ExtractFileDrive(ParamStr(0)) + '\' + '2_'+filename;
AssignFile(f,fsPath);
Rewrite(f);
Result := IOResult = 0;
CloseFile(f);
end;
function CreateEmptyFile3: Boolean;
var
fs: TFileStream;
begin
cwdPath := ExtractFilePath(ParamStr(0)) + '3_'+filename;
fs := TFileStream.Create(cwdPath,fmCreate);
fs.Free;
Result := FileExists(cwdPath);
end;
function CreateEmptyFile4: Boolean;
var
fs: TFileStream;
begin
fsPath := ExtractFileDrive(ParamStr(0)) + '\' + '4_'+filename;
fs := TFileStream.Create(fsPath,fmCreate);
fs.Free;
Result := FileExists(fsPath);
end;
begin
if CreateEmptyFile1 then
Writeln('File created at '+cwdPath)
else
Writeln('Error creating file at '+cwdPath);
if CreateEmptyFile2 then
Writeln('File created at '+fsPath)
else
Writeln('Error creating file at '+fsPath);
if CreateEmptyFile3 then
Writeln('File created at '+cwdPath)
else
Writeln('Error creating file at '+cwdPath);
if CreateEmptyFile4 then
Writeln('File created at '+fsPath)
else
Writeln('Error creating file at '+fsPath);
Readln;
end.
| #include <direct.h>
#include <fstream>
int main() {
std::fstream f("output.txt", std::ios::out);
f.close();
f.open("/output.txt", std::ios::out);
f.close();
_mkdir("docs");
_mkdir("/docs");
return 0;
}
|
Write a version of this Delphi function in Java with identical behavior. | program createFile;
uses
Classes,
SysUtils;
const
filename = 'output.txt';
var
cwdPath,
fsPath: string;
function CreateEmptyFile1: Boolean;
var
f: textfile;
begin
cwdPath := ExtractFilePath(ParamStr(0)) + '1_'+filename;
AssignFile(f,cwdPath);
Rewrite(f);
Result := IOResult = 0;
CloseFile(f);
end;
function CreateEmptyFile2: Boolean;
var
f: textfile;
begin
fsPath := ExtractFileDrive(ParamStr(0)) + '\' + '2_'+filename;
AssignFile(f,fsPath);
Rewrite(f);
Result := IOResult = 0;
CloseFile(f);
end;
function CreateEmptyFile3: Boolean;
var
fs: TFileStream;
begin
cwdPath := ExtractFilePath(ParamStr(0)) + '3_'+filename;
fs := TFileStream.Create(cwdPath,fmCreate);
fs.Free;
Result := FileExists(cwdPath);
end;
function CreateEmptyFile4: Boolean;
var
fs: TFileStream;
begin
fsPath := ExtractFileDrive(ParamStr(0)) + '\' + '4_'+filename;
fs := TFileStream.Create(fsPath,fmCreate);
fs.Free;
Result := FileExists(fsPath);
end;
begin
if CreateEmptyFile1 then
Writeln('File created at '+cwdPath)
else
Writeln('Error creating file at '+cwdPath);
if CreateEmptyFile2 then
Writeln('File created at '+fsPath)
else
Writeln('Error creating file at '+fsPath);
if CreateEmptyFile3 then
Writeln('File created at '+cwdPath)
else
Writeln('Error creating file at '+cwdPath);
if CreateEmptyFile4 then
Writeln('File created at '+fsPath)
else
Writeln('Error creating file at '+fsPath);
Readln;
end.
| import java.io.*;
public class CreateFileTest {
public static void main(String args[]) {
try {
new File("output.txt").createNewFile();
new File(File.separator + "output.txt").createNewFile();
new File("docs").mkdir();
new File(File.separator + "docs").mkdir();
} catch (IOException e) {
System.err.println(e.getMessage());
}
}
}
|
Change the following Delphi code into Python without altering its purpose. | program createFile;
uses
Classes,
SysUtils;
const
filename = 'output.txt';
var
cwdPath,
fsPath: string;
function CreateEmptyFile1: Boolean;
var
f: textfile;
begin
cwdPath := ExtractFilePath(ParamStr(0)) + '1_'+filename;
AssignFile(f,cwdPath);
Rewrite(f);
Result := IOResult = 0;
CloseFile(f);
end;
function CreateEmptyFile2: Boolean;
var
f: textfile;
begin
fsPath := ExtractFileDrive(ParamStr(0)) + '\' + '2_'+filename;
AssignFile(f,fsPath);
Rewrite(f);
Result := IOResult = 0;
CloseFile(f);
end;
function CreateEmptyFile3: Boolean;
var
fs: TFileStream;
begin
cwdPath := ExtractFilePath(ParamStr(0)) + '3_'+filename;
fs := TFileStream.Create(cwdPath,fmCreate);
fs.Free;
Result := FileExists(cwdPath);
end;
function CreateEmptyFile4: Boolean;
var
fs: TFileStream;
begin
fsPath := ExtractFileDrive(ParamStr(0)) + '\' + '4_'+filename;
fs := TFileStream.Create(fsPath,fmCreate);
fs.Free;
Result := FileExists(fsPath);
end;
begin
if CreateEmptyFile1 then
Writeln('File created at '+cwdPath)
else
Writeln('Error creating file at '+cwdPath);
if CreateEmptyFile2 then
Writeln('File created at '+fsPath)
else
Writeln('Error creating file at '+fsPath);
if CreateEmptyFile3 then
Writeln('File created at '+cwdPath)
else
Writeln('Error creating file at '+cwdPath);
if CreateEmptyFile4 then
Writeln('File created at '+fsPath)
else
Writeln('Error creating file at '+fsPath);
Readln;
end.
| import os
for directory in ['/', './']:
open(directory + 'output.txt', 'w').close()
os.mkdir(directory + 'docs')
|
Rewrite the snippet below in VB so it works the same as the original Delphi code. | program createFile;
uses
Classes,
SysUtils;
const
filename = 'output.txt';
var
cwdPath,
fsPath: string;
function CreateEmptyFile1: Boolean;
var
f: textfile;
begin
cwdPath := ExtractFilePath(ParamStr(0)) + '1_'+filename;
AssignFile(f,cwdPath);
Rewrite(f);
Result := IOResult = 0;
CloseFile(f);
end;
function CreateEmptyFile2: Boolean;
var
f: textfile;
begin
fsPath := ExtractFileDrive(ParamStr(0)) + '\' + '2_'+filename;
AssignFile(f,fsPath);
Rewrite(f);
Result := IOResult = 0;
CloseFile(f);
end;
function CreateEmptyFile3: Boolean;
var
fs: TFileStream;
begin
cwdPath := ExtractFilePath(ParamStr(0)) + '3_'+filename;
fs := TFileStream.Create(cwdPath,fmCreate);
fs.Free;
Result := FileExists(cwdPath);
end;
function CreateEmptyFile4: Boolean;
var
fs: TFileStream;
begin
fsPath := ExtractFileDrive(ParamStr(0)) + '\' + '4_'+filename;
fs := TFileStream.Create(fsPath,fmCreate);
fs.Free;
Result := FileExists(fsPath);
end;
begin
if CreateEmptyFile1 then
Writeln('File created at '+cwdPath)
else
Writeln('Error creating file at '+cwdPath);
if CreateEmptyFile2 then
Writeln('File created at '+fsPath)
else
Writeln('Error creating file at '+fsPath);
if CreateEmptyFile3 then
Writeln('File created at '+cwdPath)
else
Writeln('Error creating file at '+cwdPath);
if CreateEmptyFile4 then
Writeln('File created at '+fsPath)
else
Writeln('Error creating file at '+fsPath);
Readln;
end.
| Public Sub create_file()
Dim FileNumber As Integer
FileNumber = FreeFile
MkDir "docs"
Open "docs\output.txt" For Output As #FreeFile
Close #FreeFile
MkDir "C:\docs"
Open "C:\docs\output.txt" For Output As #FreeFile
Close #FreeFile
End Sub
|
Convert this Delphi snippet to Go and keep its semantics consistent. | program createFile;
uses
Classes,
SysUtils;
const
filename = 'output.txt';
var
cwdPath,
fsPath: string;
function CreateEmptyFile1: Boolean;
var
f: textfile;
begin
cwdPath := ExtractFilePath(ParamStr(0)) + '1_'+filename;
AssignFile(f,cwdPath);
Rewrite(f);
Result := IOResult = 0;
CloseFile(f);
end;
function CreateEmptyFile2: Boolean;
var
f: textfile;
begin
fsPath := ExtractFileDrive(ParamStr(0)) + '\' + '2_'+filename;
AssignFile(f,fsPath);
Rewrite(f);
Result := IOResult = 0;
CloseFile(f);
end;
function CreateEmptyFile3: Boolean;
var
fs: TFileStream;
begin
cwdPath := ExtractFilePath(ParamStr(0)) + '3_'+filename;
fs := TFileStream.Create(cwdPath,fmCreate);
fs.Free;
Result := FileExists(cwdPath);
end;
function CreateEmptyFile4: Boolean;
var
fs: TFileStream;
begin
fsPath := ExtractFileDrive(ParamStr(0)) + '\' + '4_'+filename;
fs := TFileStream.Create(fsPath,fmCreate);
fs.Free;
Result := FileExists(fsPath);
end;
begin
if CreateEmptyFile1 then
Writeln('File created at '+cwdPath)
else
Writeln('Error creating file at '+cwdPath);
if CreateEmptyFile2 then
Writeln('File created at '+fsPath)
else
Writeln('Error creating file at '+fsPath);
if CreateEmptyFile3 then
Writeln('File created at '+cwdPath)
else
Writeln('Error creating file at '+cwdPath);
if CreateEmptyFile4 then
Writeln('File created at '+fsPath)
else
Writeln('Error creating file at '+fsPath);
Readln;
end.
| package main
import (
"fmt"
"os"
)
func createFile(fn string) {
f, err := os.Create(fn)
if err != nil {
fmt.Println(err)
return
}
fmt.Println("file", fn, "created!")
f.Close()
}
func createDir(dn string) {
err := os.Mkdir(dn, 0666)
if err != nil {
fmt.Println(err)
return
}
fmt.Println("directory", dn, "created!")
}
func main() {
createFile("input.txt")
createFile("/input.txt")
createDir("docs")
createDir("/docs")
}
|
Convert this Elixir block to C, preserving its control flow and logic. | File.open("output.txt", [:write])
File.open("/output.txt", [:write])
File.mkdir!("docs")
File.mkdir!("/docs")
| #include <stdio.h>
int main() {
FILE *fh = fopen("output.txt", "w");
fclose(fh);
return 0;
}
|
Convert the following code from Elixir to C#, ensuring the logic remains intact. | File.open("output.txt", [:write])
File.open("/output.txt", [:write])
File.mkdir!("docs")
File.mkdir!("/docs")
| using System;
using System.IO;
class Program {
static void Main(string[] args) {
File.Create("output.txt");
File.Create(@"\output.txt");
Directory.CreateDirectory("docs");
Directory.CreateDirectory(@"\docs");
}
}
|
Port the provided Elixir code into C++ while preserving the original functionality. | File.open("output.txt", [:write])
File.open("/output.txt", [:write])
File.mkdir!("docs")
File.mkdir!("/docs")
| #include <direct.h>
#include <fstream>
int main() {
std::fstream f("output.txt", std::ios::out);
f.close();
f.open("/output.txt", std::ios::out);
f.close();
_mkdir("docs");
_mkdir("/docs");
return 0;
}
|
Produce a functionally identical Java code for the snippet given in Elixir. | File.open("output.txt", [:write])
File.open("/output.txt", [:write])
File.mkdir!("docs")
File.mkdir!("/docs")
| import java.io.*;
public class CreateFileTest {
public static void main(String args[]) {
try {
new File("output.txt").createNewFile();
new File(File.separator + "output.txt").createNewFile();
new File("docs").mkdir();
new File(File.separator + "docs").mkdir();
} catch (IOException e) {
System.err.println(e.getMessage());
}
}
}
|
Convert this Elixir block to Python, preserving its control flow and logic. | File.open("output.txt", [:write])
File.open("/output.txt", [:write])
File.mkdir!("docs")
File.mkdir!("/docs")
| import os
for directory in ['/', './']:
open(directory + 'output.txt', 'w').close()
os.mkdir(directory + 'docs')
|
Generate a VB translation of this Elixir snippet without changing its computational steps. | File.open("output.txt", [:write])
File.open("/output.txt", [:write])
File.mkdir!("docs")
File.mkdir!("/docs")
| Public Sub create_file()
Dim FileNumber As Integer
FileNumber = FreeFile
MkDir "docs"
Open "docs\output.txt" For Output As #FreeFile
Close #FreeFile
MkDir "C:\docs"
Open "C:\docs\output.txt" For Output As #FreeFile
Close #FreeFile
End Sub
|
Write the same algorithm in Go as shown in this Elixir implementation. | File.open("output.txt", [:write])
File.open("/output.txt", [:write])
File.mkdir!("docs")
File.mkdir!("/docs")
| package main
import (
"fmt"
"os"
)
func createFile(fn string) {
f, err := os.Create(fn)
if err != nil {
fmt.Println(err)
return
}
fmt.Println("file", fn, "created!")
f.Close()
}
func createDir(dn string) {
err := os.Mkdir(dn, 0666)
if err != nil {
fmt.Println(err)
return
}
fmt.Println("directory", dn, "created!")
}
func main() {
createFile("input.txt")
createFile("/input.txt")
createDir("docs")
createDir("/docs")
}
|
Port the following code from Erlang to C with equivalent syntax and logic. | -module(new_file).
-export([main/0]).
main() ->
ok = file:write_file( "output.txt", <<>> ),
ok = file:make_dir( "docs" ),
ok = file:write_file( filename:join(["/", "output.txt"]), <<>> ),
ok = file:make_dir( filename:join(["/", "docs"]) ).
| #include <stdio.h>
int main() {
FILE *fh = fopen("output.txt", "w");
fclose(fh);
return 0;
}
|
Convert this Erlang block to C#, preserving its control flow and logic. | -module(new_file).
-export([main/0]).
main() ->
ok = file:write_file( "output.txt", <<>> ),
ok = file:make_dir( "docs" ),
ok = file:write_file( filename:join(["/", "output.txt"]), <<>> ),
ok = file:make_dir( filename:join(["/", "docs"]) ).
| using System;
using System.IO;
class Program {
static void Main(string[] args) {
File.Create("output.txt");
File.Create(@"\output.txt");
Directory.CreateDirectory("docs");
Directory.CreateDirectory(@"\docs");
}
}
|
Transform the following Erlang implementation into C++, maintaining the same output and logic. | -module(new_file).
-export([main/0]).
main() ->
ok = file:write_file( "output.txt", <<>> ),
ok = file:make_dir( "docs" ),
ok = file:write_file( filename:join(["/", "output.txt"]), <<>> ),
ok = file:make_dir( filename:join(["/", "docs"]) ).
| #include <direct.h>
#include <fstream>
int main() {
std::fstream f("output.txt", std::ios::out);
f.close();
f.open("/output.txt", std::ios::out);
f.close();
_mkdir("docs");
_mkdir("/docs");
return 0;
}
|
Change the following Erlang code into Java without altering its purpose. | -module(new_file).
-export([main/0]).
main() ->
ok = file:write_file( "output.txt", <<>> ),
ok = file:make_dir( "docs" ),
ok = file:write_file( filename:join(["/", "output.txt"]), <<>> ),
ok = file:make_dir( filename:join(["/", "docs"]) ).
| import java.io.*;
public class CreateFileTest {
public static void main(String args[]) {
try {
new File("output.txt").createNewFile();
new File(File.separator + "output.txt").createNewFile();
new File("docs").mkdir();
new File(File.separator + "docs").mkdir();
} catch (IOException e) {
System.err.println(e.getMessage());
}
}
}
|
Write a version of this Erlang function in Python with identical behavior. | -module(new_file).
-export([main/0]).
main() ->
ok = file:write_file( "output.txt", <<>> ),
ok = file:make_dir( "docs" ),
ok = file:write_file( filename:join(["/", "output.txt"]), <<>> ),
ok = file:make_dir( filename:join(["/", "docs"]) ).
| import os
for directory in ['/', './']:
open(directory + 'output.txt', 'w').close()
os.mkdir(directory + 'docs')
|
Write the same algorithm in VB as shown in this Erlang implementation. | -module(new_file).
-export([main/0]).
main() ->
ok = file:write_file( "output.txt", <<>> ),
ok = file:make_dir( "docs" ),
ok = file:write_file( filename:join(["/", "output.txt"]), <<>> ),
ok = file:make_dir( filename:join(["/", "docs"]) ).
| Public Sub create_file()
Dim FileNumber As Integer
FileNumber = FreeFile
MkDir "docs"
Open "docs\output.txt" For Output As #FreeFile
Close #FreeFile
MkDir "C:\docs"
Open "C:\docs\output.txt" For Output As #FreeFile
Close #FreeFile
End Sub
|
Write the same algorithm in Go as shown in this Erlang implementation. | -module(new_file).
-export([main/0]).
main() ->
ok = file:write_file( "output.txt", <<>> ),
ok = file:make_dir( "docs" ),
ok = file:write_file( filename:join(["/", "output.txt"]), <<>> ),
ok = file:make_dir( filename:join(["/", "docs"]) ).
| package main
import (
"fmt"
"os"
)
func createFile(fn string) {
f, err := os.Create(fn)
if err != nil {
fmt.Println(err)
return
}
fmt.Println("file", fn, "created!")
f.Close()
}
func createDir(dn string) {
err := os.Mkdir(dn, 0666)
if err != nil {
fmt.Println(err)
return
}
fmt.Println("directory", dn, "created!")
}
func main() {
createFile("input.txt")
createFile("/input.txt")
createDir("docs")
createDir("/docs")
}
|
Change the programming language of this snippet from F# to C without modifying what it does. | open System.IO
[<EntryPoint>]
let main argv =
let fileName = "output.txt"
let dirName = "docs"
for path in ["."; "/"] do
ignore (File.Create(Path.Combine(path, fileName)))
ignore (Directory.CreateDirectory(Path.Combine(path, dirName)))
0
| #include <stdio.h>
int main() {
FILE *fh = fopen("output.txt", "w");
fclose(fh);
return 0;
}
|
Generate a C++ translation of this F# snippet without changing its computational steps. | open System.IO
[<EntryPoint>]
let main argv =
let fileName = "output.txt"
let dirName = "docs"
for path in ["."; "/"] do
ignore (File.Create(Path.Combine(path, fileName)))
ignore (Directory.CreateDirectory(Path.Combine(path, dirName)))
0
| #include <direct.h>
#include <fstream>
int main() {
std::fstream f("output.txt", std::ios::out);
f.close();
f.open("/output.txt", std::ios::out);
f.close();
_mkdir("docs");
_mkdir("/docs");
return 0;
}
|
Convert the following code from F# to Java, ensuring the logic remains intact. | open System.IO
[<EntryPoint>]
let main argv =
let fileName = "output.txt"
let dirName = "docs"
for path in ["."; "/"] do
ignore (File.Create(Path.Combine(path, fileName)))
ignore (Directory.CreateDirectory(Path.Combine(path, dirName)))
0
| import java.io.*;
public class CreateFileTest {
public static void main(String args[]) {
try {
new File("output.txt").createNewFile();
new File(File.separator + "output.txt").createNewFile();
new File("docs").mkdir();
new File(File.separator + "docs").mkdir();
} catch (IOException e) {
System.err.println(e.getMessage());
}
}
}
|
Translate the given F# code snippet into Python without altering its behavior. | open System.IO
[<EntryPoint>]
let main argv =
let fileName = "output.txt"
let dirName = "docs"
for path in ["."; "/"] do
ignore (File.Create(Path.Combine(path, fileName)))
ignore (Directory.CreateDirectory(Path.Combine(path, dirName)))
0
| import os
for directory in ['/', './']:
open(directory + 'output.txt', 'w').close()
os.mkdir(directory + 'docs')
|
Rewrite the snippet below in VB so it works the same as the original F# code. | open System.IO
[<EntryPoint>]
let main argv =
let fileName = "output.txt"
let dirName = "docs"
for path in ["."; "/"] do
ignore (File.Create(Path.Combine(path, fileName)))
ignore (Directory.CreateDirectory(Path.Combine(path, dirName)))
0
| Public Sub create_file()
Dim FileNumber As Integer
FileNumber = FreeFile
MkDir "docs"
Open "docs\output.txt" For Output As #FreeFile
Close #FreeFile
MkDir "C:\docs"
Open "C:\docs\output.txt" For Output As #FreeFile
Close #FreeFile
End Sub
|
Port the following code from F# to Go with equivalent syntax and logic. | open System.IO
[<EntryPoint>]
let main argv =
let fileName = "output.txt"
let dirName = "docs"
for path in ["."; "/"] do
ignore (File.Create(Path.Combine(path, fileName)))
ignore (Directory.CreateDirectory(Path.Combine(path, dirName)))
0
| package main
import (
"fmt"
"os"
)
func createFile(fn string) {
f, err := os.Create(fn)
if err != nil {
fmt.Println(err)
return
}
fmt.Println("file", fn, "created!")
f.Close()
}
func createDir(dn string) {
err := os.Mkdir(dn, 0666)
if err != nil {
fmt.Println(err)
return
}
fmt.Println("directory", dn, "created!")
}
func main() {
createFile("input.txt")
createFile("/input.txt")
createDir("docs")
createDir("/docs")
}
|
Translate this program into C but keep the logic exactly as in Factor. | USE: io.directories
"output.txt" "/output.txt" [ touch-file ] bi@
"docs" "/docs" [ make-directory ] bi@
| #include <stdio.h>
int main() {
FILE *fh = fopen("output.txt", "w");
fclose(fh);
return 0;
}
|
Generate an equivalent C# version of this Factor code. | USE: io.directories
"output.txt" "/output.txt" [ touch-file ] bi@
"docs" "/docs" [ make-directory ] bi@
| using System;
using System.IO;
class Program {
static void Main(string[] args) {
File.Create("output.txt");
File.Create(@"\output.txt");
Directory.CreateDirectory("docs");
Directory.CreateDirectory(@"\docs");
}
}
|
Please provide an equivalent version of this Factor code in C++. | USE: io.directories
"output.txt" "/output.txt" [ touch-file ] bi@
"docs" "/docs" [ make-directory ] bi@
| #include <direct.h>
#include <fstream>
int main() {
std::fstream f("output.txt", std::ios::out);
f.close();
f.open("/output.txt", std::ios::out);
f.close();
_mkdir("docs");
_mkdir("/docs");
return 0;
}
|
Convert this Factor block to Java, preserving its control flow and logic. | USE: io.directories
"output.txt" "/output.txt" [ touch-file ] bi@
"docs" "/docs" [ make-directory ] bi@
| import java.io.*;
public class CreateFileTest {
public static void main(String args[]) {
try {
new File("output.txt").createNewFile();
new File(File.separator + "output.txt").createNewFile();
new File("docs").mkdir();
new File(File.separator + "docs").mkdir();
} catch (IOException e) {
System.err.println(e.getMessage());
}
}
}
|
Rewrite the snippet below in Python so it works the same as the original Factor code. | USE: io.directories
"output.txt" "/output.txt" [ touch-file ] bi@
"docs" "/docs" [ make-directory ] bi@
| import os
for directory in ['/', './']:
open(directory + 'output.txt', 'w').close()
os.mkdir(directory + 'docs')
|
Port the provided Factor code into VB while preserving the original functionality. | USE: io.directories
"output.txt" "/output.txt" [ touch-file ] bi@
"docs" "/docs" [ make-directory ] bi@
| Public Sub create_file()
Dim FileNumber As Integer
FileNumber = FreeFile
MkDir "docs"
Open "docs\output.txt" For Output As #FreeFile
Close #FreeFile
MkDir "C:\docs"
Open "C:\docs\output.txt" For Output As #FreeFile
Close #FreeFile
End Sub
|
Port the provided Factor code into Go while preserving the original functionality. | USE: io.directories
"output.txt" "/output.txt" [ touch-file ] bi@
"docs" "/docs" [ make-directory ] bi@
| package main
import (
"fmt"
"os"
)
func createFile(fn string) {
f, err := os.Create(fn)
if err != nil {
fmt.Println(err)
return
}
fmt.Println("file", fn, "created!")
f.Close()
}
func createDir(dn string) {
err := os.Mkdir(dn, 0666)
if err != nil {
fmt.Println(err)
return
}
fmt.Println("directory", dn, "created!")
}
func main() {
createFile("input.txt")
createFile("/input.txt")
createDir("docs")
createDir("/docs")
}
|
Keep all operations the same but rewrite the snippet in C. | s" output.txt" w/o create-file throw drop
s" /output.txt" w/o create-file throw drop
| #include <stdio.h>
int main() {
FILE *fh = fopen("output.txt", "w");
fclose(fh);
return 0;
}
|
Please provide an equivalent version of this Forth code in C#. | s" output.txt" w/o create-file throw drop
s" /output.txt" w/o create-file throw drop
| using System;
using System.IO;
class Program {
static void Main(string[] args) {
File.Create("output.txt");
File.Create(@"\output.txt");
Directory.CreateDirectory("docs");
Directory.CreateDirectory(@"\docs");
}
}
|
Can you help me rewrite this code in C++ instead of Forth, keeping it the same logically? | s" output.txt" w/o create-file throw drop
s" /output.txt" w/o create-file throw drop
| #include <direct.h>
#include <fstream>
int main() {
std::fstream f("output.txt", std::ios::out);
f.close();
f.open("/output.txt", std::ios::out);
f.close();
_mkdir("docs");
_mkdir("/docs");
return 0;
}
|
Keep all operations the same but rewrite the snippet in Java. | s" output.txt" w/o create-file throw drop
s" /output.txt" w/o create-file throw drop
| import java.io.*;
public class CreateFileTest {
public static void main(String args[]) {
try {
new File("output.txt").createNewFile();
new File(File.separator + "output.txt").createNewFile();
new File("docs").mkdir();
new File(File.separator + "docs").mkdir();
} catch (IOException e) {
System.err.println(e.getMessage());
}
}
}
|
Transform the following Forth implementation into Python, maintaining the same output and logic. | s" output.txt" w/o create-file throw drop
s" /output.txt" w/o create-file throw drop
| import os
for directory in ['/', './']:
open(directory + 'output.txt', 'w').close()
os.mkdir(directory + 'docs')
|
Ensure the translated VB code behaves exactly like the original Forth snippet. | s" output.txt" w/o create-file throw drop
s" /output.txt" w/o create-file throw drop
| Public Sub create_file()
Dim FileNumber As Integer
FileNumber = FreeFile
MkDir "docs"
Open "docs\output.txt" For Output As #FreeFile
Close #FreeFile
MkDir "C:\docs"
Open "C:\docs\output.txt" For Output As #FreeFile
Close #FreeFile
End Sub
|
Rewrite this program in Go while keeping its functionality equivalent to the Forth version. | s" output.txt" w/o create-file throw drop
s" /output.txt" w/o create-file throw drop
| package main
import (
"fmt"
"os"
)
func createFile(fn string) {
f, err := os.Create(fn)
if err != nil {
fmt.Println(err)
return
}
fmt.Println("file", fn, "created!")
f.Close()
}
func createDir(dn string) {
err := os.Mkdir(dn, 0666)
if err != nil {
fmt.Println(err)
return
}
fmt.Println("directory", dn, "created!")
}
func main() {
createFile("input.txt")
createFile("/input.txt")
createDir("docs")
createDir("/docs")
}
|
Port the following code from Fortran to C# with equivalent syntax and logic. | PROGRAM CREATION
OPEN (UNIT=5, FILE="output.txt", STATUS="NEW")
CLOSE (UNIT=5)
OPEN (UNIT=5, FILE="/output.txt", STATUS="NEW")
CLOSE (UNIT=5)
call system("mkdir docs/")
call system("mkdir ~/docs/")
END PROGRAM
| using System;
using System.IO;
class Program {
static void Main(string[] args) {
File.Create("output.txt");
File.Create(@"\output.txt");
Directory.CreateDirectory("docs");
Directory.CreateDirectory(@"\docs");
}
}
|
Write the same code in C++ as shown below in Fortran. | PROGRAM CREATION
OPEN (UNIT=5, FILE="output.txt", STATUS="NEW")
CLOSE (UNIT=5)
OPEN (UNIT=5, FILE="/output.txt", STATUS="NEW")
CLOSE (UNIT=5)
call system("mkdir docs/")
call system("mkdir ~/docs/")
END PROGRAM
| #include <direct.h>
#include <fstream>
int main() {
std::fstream f("output.txt", std::ios::out);
f.close();
f.open("/output.txt", std::ios::out);
f.close();
_mkdir("docs");
_mkdir("/docs");
return 0;
}
|
Port the following code from Fortran to C with equivalent syntax and logic. | PROGRAM CREATION
OPEN (UNIT=5, FILE="output.txt", STATUS="NEW")
CLOSE (UNIT=5)
OPEN (UNIT=5, FILE="/output.txt", STATUS="NEW")
CLOSE (UNIT=5)
call system("mkdir docs/")
call system("mkdir ~/docs/")
END PROGRAM
| #include <stdio.h>
int main() {
FILE *fh = fopen("output.txt", "w");
fclose(fh);
return 0;
}
|
Ensure the translated Java code behaves exactly like the original Fortran snippet. | PROGRAM CREATION
OPEN (UNIT=5, FILE="output.txt", STATUS="NEW")
CLOSE (UNIT=5)
OPEN (UNIT=5, FILE="/output.txt", STATUS="NEW")
CLOSE (UNIT=5)
call system("mkdir docs/")
call system("mkdir ~/docs/")
END PROGRAM
| import java.io.*;
public class CreateFileTest {
public static void main(String args[]) {
try {
new File("output.txt").createNewFile();
new File(File.separator + "output.txt").createNewFile();
new File("docs").mkdir();
new File(File.separator + "docs").mkdir();
} catch (IOException e) {
System.err.println(e.getMessage());
}
}
}
|
Generate an equivalent Python version of this Fortran code. | PROGRAM CREATION
OPEN (UNIT=5, FILE="output.txt", STATUS="NEW")
CLOSE (UNIT=5)
OPEN (UNIT=5, FILE="/output.txt", STATUS="NEW")
CLOSE (UNIT=5)
call system("mkdir docs/")
call system("mkdir ~/docs/")
END PROGRAM
| import os
for directory in ['/', './']:
open(directory + 'output.txt', 'w').close()
os.mkdir(directory + 'docs')
|
Convert this Fortran block to VB, preserving its control flow and logic. | PROGRAM CREATION
OPEN (UNIT=5, FILE="output.txt", STATUS="NEW")
CLOSE (UNIT=5)
OPEN (UNIT=5, FILE="/output.txt", STATUS="NEW")
CLOSE (UNIT=5)
call system("mkdir docs/")
call system("mkdir ~/docs/")
END PROGRAM
| Public Sub create_file()
Dim FileNumber As Integer
FileNumber = FreeFile
MkDir "docs"
Open "docs\output.txt" For Output As #FreeFile
Close #FreeFile
MkDir "C:\docs"
Open "C:\docs\output.txt" For Output As #FreeFile
Close #FreeFile
End Sub
|
Write the same code in PHP as shown below in Fortran. | PROGRAM CREATION
OPEN (UNIT=5, FILE="output.txt", STATUS="NEW")
CLOSE (UNIT=5)
OPEN (UNIT=5, FILE="/output.txt", STATUS="NEW")
CLOSE (UNIT=5)
call system("mkdir docs/")
call system("mkdir ~/docs/")
END PROGRAM
| <?php
touch('output.txt');
mkdir('docs');
touch('/output.txt');
mkdir('/docs');
?>
|
Write the same algorithm in C as shown in this Groovy implementation. | new File("output.txt").createNewFile()
new File(File.separator + "output.txt").createNewFile()
new File("docs").mkdir()
new File(File.separator + "docs").mkdir()
| #include <stdio.h>
int main() {
FILE *fh = fopen("output.txt", "w");
fclose(fh);
return 0;
}
|
Convert this Groovy snippet to C# and keep its semantics consistent. | new File("output.txt").createNewFile()
new File(File.separator + "output.txt").createNewFile()
new File("docs").mkdir()
new File(File.separator + "docs").mkdir()
| using System;
using System.IO;
class Program {
static void Main(string[] args) {
File.Create("output.txt");
File.Create(@"\output.txt");
Directory.CreateDirectory("docs");
Directory.CreateDirectory(@"\docs");
}
}
|
Please provide an equivalent version of this Groovy code in C++. | new File("output.txt").createNewFile()
new File(File.separator + "output.txt").createNewFile()
new File("docs").mkdir()
new File(File.separator + "docs").mkdir()
| #include <direct.h>
#include <fstream>
int main() {
std::fstream f("output.txt", std::ios::out);
f.close();
f.open("/output.txt", std::ios::out);
f.close();
_mkdir("docs");
_mkdir("/docs");
return 0;
}
|
Translate the given Groovy code snippet into Java without altering its behavior. | new File("output.txt").createNewFile()
new File(File.separator + "output.txt").createNewFile()
new File("docs").mkdir()
new File(File.separator + "docs").mkdir()
| import java.io.*;
public class CreateFileTest {
public static void main(String args[]) {
try {
new File("output.txt").createNewFile();
new File(File.separator + "output.txt").createNewFile();
new File("docs").mkdir();
new File(File.separator + "docs").mkdir();
} catch (IOException e) {
System.err.println(e.getMessage());
}
}
}
|
Convert this Groovy block to Python, preserving its control flow and logic. | new File("output.txt").createNewFile()
new File(File.separator + "output.txt").createNewFile()
new File("docs").mkdir()
new File(File.separator + "docs").mkdir()
| import os
for directory in ['/', './']:
open(directory + 'output.txt', 'w').close()
os.mkdir(directory + 'docs')
|
Produce a functionally identical VB code for the snippet given in Groovy. | new File("output.txt").createNewFile()
new File(File.separator + "output.txt").createNewFile()
new File("docs").mkdir()
new File(File.separator + "docs").mkdir()
| Public Sub create_file()
Dim FileNumber As Integer
FileNumber = FreeFile
MkDir "docs"
Open "docs\output.txt" For Output As #FreeFile
Close #FreeFile
MkDir "C:\docs"
Open "C:\docs\output.txt" For Output As #FreeFile
Close #FreeFile
End Sub
|
Translate this program into Go but keep the logic exactly as in Groovy. | new File("output.txt").createNewFile()
new File(File.separator + "output.txt").createNewFile()
new File("docs").mkdir()
new File(File.separator + "docs").mkdir()
| package main
import (
"fmt"
"os"
)
func createFile(fn string) {
f, err := os.Create(fn)
if err != nil {
fmt.Println(err)
return
}
fmt.Println("file", fn, "created!")
f.Close()
}
func createDir(dn string) {
err := os.Mkdir(dn, 0666)
if err != nil {
fmt.Println(err)
return
}
fmt.Println("directory", dn, "created!")
}
func main() {
createFile("input.txt")
createFile("/input.txt")
createDir("docs")
createDir("/docs")
}
|
Translate this program into C but keep the logic exactly as in Haskell. | import System.Directory
createFile name = writeFile name ""
main = do
createFile "output.txt"
createDirectory "docs"
createFile "/output.txt"
createDirectory "/docs"
| #include <stdio.h>
int main() {
FILE *fh = fopen("output.txt", "w");
fclose(fh);
return 0;
}
|
Write a version of this Haskell function in C# with identical behavior. | import System.Directory
createFile name = writeFile name ""
main = do
createFile "output.txt"
createDirectory "docs"
createFile "/output.txt"
createDirectory "/docs"
| using System;
using System.IO;
class Program {
static void Main(string[] args) {
File.Create("output.txt");
File.Create(@"\output.txt");
Directory.CreateDirectory("docs");
Directory.CreateDirectory(@"\docs");
}
}
|
Port the following code from Haskell to C++ with equivalent syntax and logic. | import System.Directory
createFile name = writeFile name ""
main = do
createFile "output.txt"
createDirectory "docs"
createFile "/output.txt"
createDirectory "/docs"
| #include <direct.h>
#include <fstream>
int main() {
std::fstream f("output.txt", std::ios::out);
f.close();
f.open("/output.txt", std::ios::out);
f.close();
_mkdir("docs");
_mkdir("/docs");
return 0;
}
|
Please provide an equivalent version of this Haskell code in Java. | import System.Directory
createFile name = writeFile name ""
main = do
createFile "output.txt"
createDirectory "docs"
createFile "/output.txt"
createDirectory "/docs"
| import java.io.*;
public class CreateFileTest {
public static void main(String args[]) {
try {
new File("output.txt").createNewFile();
new File(File.separator + "output.txt").createNewFile();
new File("docs").mkdir();
new File(File.separator + "docs").mkdir();
} catch (IOException e) {
System.err.println(e.getMessage());
}
}
}
|
Translate this program into Python but keep the logic exactly as in Haskell. | import System.Directory
createFile name = writeFile name ""
main = do
createFile "output.txt"
createDirectory "docs"
createFile "/output.txt"
createDirectory "/docs"
| import os
for directory in ['/', './']:
open(directory + 'output.txt', 'w').close()
os.mkdir(directory + 'docs')
|
Rewrite this program in VB while keeping its functionality equivalent to the Haskell version. | import System.Directory
createFile name = writeFile name ""
main = do
createFile "output.txt"
createDirectory "docs"
createFile "/output.txt"
createDirectory "/docs"
| Public Sub create_file()
Dim FileNumber As Integer
FileNumber = FreeFile
MkDir "docs"
Open "docs\output.txt" For Output As #FreeFile
Close #FreeFile
MkDir "C:\docs"
Open "C:\docs\output.txt" For Output As #FreeFile
Close #FreeFile
End Sub
|
Convert this Haskell snippet to Go and keep its semantics consistent. | import System.Directory
createFile name = writeFile name ""
main = do
createFile "output.txt"
createDirectory "docs"
createFile "/output.txt"
createDirectory "/docs"
| package main
import (
"fmt"
"os"
)
func createFile(fn string) {
f, err := os.Create(fn)
if err != nil {
fmt.Println(err)
return
}
fmt.Println("file", fn, "created!")
f.Close()
}
func createDir(dn string) {
err := os.Mkdir(dn, 0666)
if err != nil {
fmt.Println(err)
return
}
fmt.Println("directory", dn, "created!")
}
func main() {
createFile("input.txt")
createFile("/input.txt")
createDir("docs")
createDir("/docs")
}
|
Change the programming language of this snippet from J to C without modifying what it does. | '' 1!:2 <'/output.txt'
1!:5 <'/docs'
| #include <stdio.h>
int main() {
FILE *fh = fopen("output.txt", "w");
fclose(fh);
return 0;
}
|
Produce a functionally identical C# code for the snippet given in J. | '' 1!:2 <'/output.txt'
1!:5 <'/docs'
| using System;
using System.IO;
class Program {
static void Main(string[] args) {
File.Create("output.txt");
File.Create(@"\output.txt");
Directory.CreateDirectory("docs");
Directory.CreateDirectory(@"\docs");
}
}
|
Translate this program into C++ but keep the logic exactly as in J. | '' 1!:2 <'/output.txt'
1!:5 <'/docs'
| #include <direct.h>
#include <fstream>
int main() {
std::fstream f("output.txt", std::ios::out);
f.close();
f.open("/output.txt", std::ios::out);
f.close();
_mkdir("docs");
_mkdir("/docs");
return 0;
}
|
Maintain the same structure and functionality when rewriting this code in Java. | '' 1!:2 <'/output.txt'
1!:5 <'/docs'
| import java.io.*;
public class CreateFileTest {
public static void main(String args[]) {
try {
new File("output.txt").createNewFile();
new File(File.separator + "output.txt").createNewFile();
new File("docs").mkdir();
new File(File.separator + "docs").mkdir();
} catch (IOException e) {
System.err.println(e.getMessage());
}
}
}
|
Write a version of this J function in Python with identical behavior. | '' 1!:2 <'/output.txt'
1!:5 <'/docs'
| import os
for directory in ['/', './']:
open(directory + 'output.txt', 'w').close()
os.mkdir(directory + 'docs')
|
Write a version of this J function in VB with identical behavior. | '' 1!:2 <'/output.txt'
1!:5 <'/docs'
| Public Sub create_file()
Dim FileNumber As Integer
FileNumber = FreeFile
MkDir "docs"
Open "docs\output.txt" For Output As #FreeFile
Close #FreeFile
MkDir "C:\docs"
Open "C:\docs\output.txt" For Output As #FreeFile
Close #FreeFile
End Sub
|
Produce a functionally identical Go code for the snippet given in J. | '' 1!:2 <'/output.txt'
1!:5 <'/docs'
| package main
import (
"fmt"
"os"
)
func createFile(fn string) {
f, err := os.Create(fn)
if err != nil {
fmt.Println(err)
return
}
fmt.Println("file", fn, "created!")
f.Close()
}
func createDir(dn string) {
err := os.Mkdir(dn, 0666)
if err != nil {
fmt.Println(err)
return
}
fmt.Println("directory", dn, "created!")
}
func main() {
createFile("input.txt")
createFile("/input.txt")
createDir("docs")
createDir("/docs")
}
|
Transform the following Julia implementation into C, maintaining the same output and logic. |
touch("output.txt")
mkdir("docs")
try
touch("/output.txt")
mkdir("/docs")
catch e
warn(e)
end
| #include <stdio.h>
int main() {
FILE *fh = fopen("output.txt", "w");
fclose(fh);
return 0;
}
|
Generate an equivalent C# version of this Julia code. |
touch("output.txt")
mkdir("docs")
try
touch("/output.txt")
mkdir("/docs")
catch e
warn(e)
end
| using System;
using System.IO;
class Program {
static void Main(string[] args) {
File.Create("output.txt");
File.Create(@"\output.txt");
Directory.CreateDirectory("docs");
Directory.CreateDirectory(@"\docs");
}
}
|
Port the provided Julia code into C++ while preserving the original functionality. |
touch("output.txt")
mkdir("docs")
try
touch("/output.txt")
mkdir("/docs")
catch e
warn(e)
end
| #include <direct.h>
#include <fstream>
int main() {
std::fstream f("output.txt", std::ios::out);
f.close();
f.open("/output.txt", std::ios::out);
f.close();
_mkdir("docs");
_mkdir("/docs");
return 0;
}
|
Produce a functionally identical Java code for the snippet given in Julia. |
touch("output.txt")
mkdir("docs")
try
touch("/output.txt")
mkdir("/docs")
catch e
warn(e)
end
| import java.io.*;
public class CreateFileTest {
public static void main(String args[]) {
try {
new File("output.txt").createNewFile();
new File(File.separator + "output.txt").createNewFile();
new File("docs").mkdir();
new File(File.separator + "docs").mkdir();
} catch (IOException e) {
System.err.println(e.getMessage());
}
}
}
|
Write the same code in Python as shown below in Julia. |
touch("output.txt")
mkdir("docs")
try
touch("/output.txt")
mkdir("/docs")
catch e
warn(e)
end
| import os
for directory in ['/', './']:
open(directory + 'output.txt', 'w').close()
os.mkdir(directory + 'docs')
|
Ensure the translated VB code behaves exactly like the original Julia snippet. |
touch("output.txt")
mkdir("docs")
try
touch("/output.txt")
mkdir("/docs")
catch e
warn(e)
end
| Public Sub create_file()
Dim FileNumber As Integer
FileNumber = FreeFile
MkDir "docs"
Open "docs\output.txt" For Output As #FreeFile
Close #FreeFile
MkDir "C:\docs"
Open "C:\docs\output.txt" For Output As #FreeFile
Close #FreeFile
End Sub
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.