Instruction stringlengths 45 106 | input_code stringlengths 1 13.7k | output_code stringlengths 1 13.7k |
|---|---|---|
Ensure the translated Go code behaves exactly like the original Julia snippet. |
touch("output.txt")
mkdir("docs")
try
touch("/output.txt")
mkdir("/docs")
catch e
warn(e)
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 Lua block to C, preserving its control flow and logic. | io.open("output.txt", "w"):close()
io.open("\\output.txt", "w"):close()
| #include <stdio.h>
int main() {
FILE *fh = fopen("output.txt", "w");
fclose(fh);
return 0;
}
|
Transform the following Lua implementation into C#, maintaining the same output and logic. | io.open("output.txt", "w"):close()
io.open("\\output.txt", "w"):close()
| 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 the snippet below in C++ so it works the same as the original Lua code. | io.open("output.txt", "w"):close()
io.open("\\output.txt", "w"):close()
| #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 this program into Java but keep the logic exactly as in Lua. | io.open("output.txt", "w"):close()
io.open("\\output.txt", "w"):close()
| 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 Lua implementation into Python, maintaining the same output and logic. | io.open("output.txt", "w"):close()
io.open("\\output.txt", "w"):close()
| import os
for directory in ['/', './']:
open(directory + 'output.txt', 'w').close()
os.mkdir(directory + 'docs')
|
Preserve the algorithm and functionality while converting the code from Lua to VB. | io.open("output.txt", "w"):close()
io.open("\\output.txt", "w"):close()
| 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 Lua. | io.open("output.txt", "w"):close()
io.open("\\output.txt", "w"):close()
| 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")
}
|
Generate an equivalent C version of this Mathematica code. | SetDirectory@NotebookDirectory[];
t = OpenWrite["output.txt"]
Close[t]
s = OpenWrite[First@FileNameSplit[$InstallationDirectory] <> "\\output.txt"]
Close[s]
CreateDirectory["\\docs"]
CreateDirectory[Directory[]<>"\\docs"]
| #include <stdio.h>
int main() {
FILE *fh = fopen("output.txt", "w");
fclose(fh);
return 0;
}
|
Port the following code from Mathematica to C# with equivalent syntax and logic. | SetDirectory@NotebookDirectory[];
t = OpenWrite["output.txt"]
Close[t]
s = OpenWrite[First@FileNameSplit[$InstallationDirectory] <> "\\output.txt"]
Close[s]
CreateDirectory["\\docs"]
CreateDirectory[Directory[]<>"\\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 a C++ translation of this Mathematica snippet without changing its computational steps. | SetDirectory@NotebookDirectory[];
t = OpenWrite["output.txt"]
Close[t]
s = OpenWrite[First@FileNameSplit[$InstallationDirectory] <> "\\output.txt"]
Close[s]
CreateDirectory["\\docs"]
CreateDirectory[Directory[]<>"\\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;
}
|
Write a version of this Mathematica function in Java with identical behavior. | SetDirectory@NotebookDirectory[];
t = OpenWrite["output.txt"]
Close[t]
s = OpenWrite[First@FileNameSplit[$InstallationDirectory] <> "\\output.txt"]
Close[s]
CreateDirectory["\\docs"]
CreateDirectory[Directory[]<>"\\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());
}
}
}
|
Produce a functionally identical Python code for the snippet given in Mathematica. | SetDirectory@NotebookDirectory[];
t = OpenWrite["output.txt"]
Close[t]
s = OpenWrite[First@FileNameSplit[$InstallationDirectory] <> "\\output.txt"]
Close[s]
CreateDirectory["\\docs"]
CreateDirectory[Directory[]<>"\\docs"]
| import os
for directory in ['/', './']:
open(directory + 'output.txt', 'w').close()
os.mkdir(directory + 'docs')
|
Can you help me rewrite this code in VB instead of Mathematica, keeping it the same logically? | SetDirectory@NotebookDirectory[];
t = OpenWrite["output.txt"]
Close[t]
s = OpenWrite[First@FileNameSplit[$InstallationDirectory] <> "\\output.txt"]
Close[s]
CreateDirectory["\\docs"]
CreateDirectory[Directory[]<>"\\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 Mathematica code snippet into Go without altering its behavior. | SetDirectory@NotebookDirectory[];
t = OpenWrite["output.txt"]
Close[t]
s = OpenWrite[First@FileNameSplit[$InstallationDirectory] <> "\\output.txt"]
Close[s]
CreateDirectory["\\docs"]
CreateDirectory[Directory[]<>"\\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 MATLAB to C without modifying what it does. | fid = fopen('output.txt','w'); fclose(fid);
fid = fopen('/output.txt','w'); fclose(fid);
mkdir('docs');
mkdir('/docs');
| #include <stdio.h>
int main() {
FILE *fh = fopen("output.txt", "w");
fclose(fh);
return 0;
}
|
Keep all operations the same but rewrite the snippet in C#. | fid = fopen('output.txt','w'); fclose(fid);
fid = fopen('/output.txt','w'); fclose(fid);
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");
}
}
|
Rewrite this program in C++ while keeping its functionality equivalent to the MATLAB version. | fid = fopen('output.txt','w'); fclose(fid);
fid = fopen('/output.txt','w'); fclose(fid);
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;
}
|
Preserve the algorithm and functionality while converting the code from MATLAB to Java. | fid = fopen('output.txt','w'); fclose(fid);
fid = fopen('/output.txt','w'); fclose(fid);
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 this MATLAB block to Python, preserving its control flow and logic. | fid = fopen('output.txt','w'); fclose(fid);
fid = fopen('/output.txt','w'); fclose(fid);
mkdir('docs');
mkdir('/docs');
| 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 MATLAB snippet. | fid = fopen('output.txt','w'); fclose(fid);
fid = fopen('/output.txt','w'); fclose(fid);
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
|
Change the programming language of this snippet from MATLAB to Go without modifying what it does. | fid = fopen('output.txt','w'); fclose(fid);
fid = fopen('/output.txt','w'); fclose(fid);
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")
}
|
Change the programming language of this snippet from Nim to C without modifying what it does. | import os
open("output.txt", fmWrite).close()
createDir("docs")
open(DirSep & "output.txt", fmWrite).close()
createDir(DirSep & "docs")
| #include <stdio.h>
int main() {
FILE *fh = fopen("output.txt", "w");
fclose(fh);
return 0;
}
|
Maintain the same structure and functionality when rewriting this code in C#. | import os
open("output.txt", fmWrite).close()
createDir("docs")
open(DirSep & "output.txt", fmWrite).close()
createDir(DirSep & "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 the snippet below in C++ so it works the same as the original Nim code. | import os
open("output.txt", fmWrite).close()
createDir("docs")
open(DirSep & "output.txt", fmWrite).close()
createDir(DirSep & "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;
}
|
Convert this Nim snippet to Java and keep its semantics consistent. | import os
open("output.txt", fmWrite).close()
createDir("docs")
open(DirSep & "output.txt", fmWrite).close()
createDir(DirSep & "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());
}
}
}
|
Transform the following Nim implementation into Python, maintaining the same output and logic. | import os
open("output.txt", fmWrite).close()
createDir("docs")
open(DirSep & "output.txt", fmWrite).close()
createDir(DirSep & "docs")
| import os
for directory in ['/', './']:
open(directory + 'output.txt', 'w').close()
os.mkdir(directory + 'docs')
|
Port the following code from Nim to VB with equivalent syntax and logic. | import os
open("output.txt", fmWrite).close()
createDir("docs")
open(DirSep & "output.txt", fmWrite).close()
createDir(DirSep & "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 Nim snippet to Go and keep its semantics consistent. | import os
open("output.txt", fmWrite).close()
createDir("docs")
open(DirSep & "output.txt", fmWrite).close()
createDir(DirSep & "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")
}
|
Keep all operations the same but rewrite the snippet in C. | # let oc = open_out "output.txt" in
close_out oc;;
- : unit = ()
# Unix.mkdir "docs" 0o750 ;;
- : unit = ()
| #include <stdio.h>
int main() {
FILE *fh = fopen("output.txt", "w");
fclose(fh);
return 0;
}
|
Port the following code from OCaml to C# with equivalent syntax and logic. | # let oc = open_out "output.txt" in
close_out oc;;
- : unit = ()
# Unix.mkdir "docs" 0o750 ;;
- : unit = ()
| 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 OCaml code in C++. | # let oc = open_out "output.txt" in
close_out oc;;
- : unit = ()
# Unix.mkdir "docs" 0o750 ;;
- : unit = ()
| #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 OCaml snippet. | # let oc = open_out "output.txt" in
close_out oc;;
- : unit = ()
# Unix.mkdir "docs" 0o750 ;;
- : unit = ()
| 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 OCaml to Python, ensuring the logic remains intact. | # let oc = open_out "output.txt" in
close_out oc;;
- : unit = ()
# Unix.mkdir "docs" 0o750 ;;
- : unit = ()
| import os
for directory in ['/', './']:
open(directory + 'output.txt', 'w').close()
os.mkdir(directory + 'docs')
|
Change the programming language of this snippet from OCaml to VB without modifying what it does. | # let oc = open_out "output.txt" in
close_out oc;;
- : unit = ()
# Unix.mkdir "docs" 0o750 ;;
- : unit = ()
| 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
|
Ensure the translated Go code behaves exactly like the original OCaml snippet. | # let oc = open_out "output.txt" in
close_out oc;;
- : unit = ()
# Unix.mkdir "docs" 0o750 ;;
- : unit = ()
| 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")
}
|
Please provide an equivalent version of this Perl code in C. | use File::Spec::Functions qw(catfile rootdir);
{
open my $fh, '>', 'output.txt';
mkdir 'docs';
};
{
open my $fh, '>', catfile rootdir, 'output.txt';
mkdir catfile rootdir, 'docs';
};
| #include <stdio.h>
int main() {
FILE *fh = fopen("output.txt", "w");
fclose(fh);
return 0;
}
|
Generate an equivalent C# version of this Perl code. | use File::Spec::Functions qw(catfile rootdir);
{
open my $fh, '>', 'output.txt';
mkdir 'docs';
};
{
open my $fh, '>', catfile rootdir, 'output.txt';
mkdir catfile rootdir, '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");
}
}
|
Write a version of this Perl function in C++ with identical behavior. | use File::Spec::Functions qw(catfile rootdir);
{
open my $fh, '>', 'output.txt';
mkdir 'docs';
};
{
open my $fh, '>', catfile rootdir, 'output.txt';
mkdir catfile rootdir, '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 language-to-language conversion: from Perl to Java, same semantics. | use File::Spec::Functions qw(catfile rootdir);
{
open my $fh, '>', 'output.txt';
mkdir 'docs';
};
{
open my $fh, '>', catfile rootdir, 'output.txt';
mkdir catfile rootdir, '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 Perl to Python, ensuring the logic remains intact. | use File::Spec::Functions qw(catfile rootdir);
{
open my $fh, '>', 'output.txt';
mkdir 'docs';
};
{
open my $fh, '>', catfile rootdir, 'output.txt';
mkdir catfile rootdir, 'docs';
};
| 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 Perl snippet. | use File::Spec::Functions qw(catfile rootdir);
{
open my $fh, '>', 'output.txt';
mkdir 'docs';
};
{
open my $fh, '>', catfile rootdir, 'output.txt';
mkdir catfile rootdir, '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 Perl to Go, ensuring the logic remains intact. | use File::Spec::Functions qw(catfile rootdir);
{
open my $fh, '>', 'output.txt';
mkdir 'docs';
};
{
open my $fh, '>', catfile rootdir, 'output.txt';
mkdir catfile rootdir, '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")
}
|
Rewrite the snippet below in C so it works the same as the original PowerShell code. | New-Item output.txt -ItemType File
New-Item \output.txt -ItemType File
New-Item docs -ItemType Directory
New-Item \docs -ItemType Directory
| #include <stdio.h>
int main() {
FILE *fh = fopen("output.txt", "w");
fclose(fh);
return 0;
}
|
Keep all operations the same but rewrite the snippet in C#. | New-Item output.txt -ItemType File
New-Item \output.txt -ItemType File
New-Item docs -ItemType Directory
New-Item \docs -ItemType Directory
| 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 a version of this PowerShell function in C++ with identical behavior. | New-Item output.txt -ItemType File
New-Item \output.txt -ItemType File
New-Item docs -ItemType Directory
New-Item \docs -ItemType Directory
| #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 PowerShell code. | New-Item output.txt -ItemType File
New-Item \output.txt -ItemType File
New-Item docs -ItemType Directory
New-Item \docs -ItemType Directory
| 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());
}
}
}
|
Produce a language-to-language conversion: from PowerShell to Python, same semantics. | New-Item output.txt -ItemType File
New-Item \output.txt -ItemType File
New-Item docs -ItemType Directory
New-Item \docs -ItemType Directory
| import os
for directory in ['/', './']:
open(directory + 'output.txt', 'w').close()
os.mkdir(directory + 'docs')
|
Translate the given PowerShell code snippet into VB without altering its behavior. | New-Item output.txt -ItemType File
New-Item \output.txt -ItemType File
New-Item docs -ItemType Directory
New-Item \docs -ItemType Directory
| 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 PowerShell code into Go while preserving the original functionality. | New-Item output.txt -ItemType File
New-Item \output.txt -ItemType File
New-Item docs -ItemType Directory
New-Item \docs -ItemType Directory
| 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")
}
|
Generate a C translation of this R snippet without changing its computational steps. | f <- file("output.txt", "w")
close(f)
f <- file("/output.txt", "w")
close(f)
success <- dir.create("docs")
success <- dir.create("/docs")
| #include <stdio.h>
int main() {
FILE *fh = fopen("output.txt", "w");
fclose(fh);
return 0;
}
|
Convert this R block to C#, preserving its control flow and logic. | f <- file("output.txt", "w")
close(f)
f <- file("/output.txt", "w")
close(f)
success <- dir.create("docs")
success <- dir.create("/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");
}
}
|
Write the same algorithm in C++ as shown in this R implementation. | f <- file("output.txt", "w")
close(f)
f <- file("/output.txt", "w")
close(f)
success <- dir.create("docs")
success <- dir.create("/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 language-to-language conversion: from R to Java, same semantics. | f <- file("output.txt", "w")
close(f)
f <- file("/output.txt", "w")
close(f)
success <- dir.create("docs")
success <- dir.create("/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());
}
}
}
|
Please provide an equivalent version of this R code in Python. | f <- file("output.txt", "w")
close(f)
f <- file("/output.txt", "w")
close(f)
success <- dir.create("docs")
success <- dir.create("/docs")
| import os
for directory in ['/', './']:
open(directory + 'output.txt', 'w').close()
os.mkdir(directory + 'docs')
|
Convert this R block to VB, preserving its control flow and logic. | f <- file("output.txt", "w")
close(f)
f <- file("/output.txt", "w")
close(f)
success <- dir.create("docs")
success <- dir.create("/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 R implementation. | f <- file("output.txt", "w")
close(f)
f <- file("/output.txt", "w")
close(f)
success <- dir.create("docs")
success <- dir.create("/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 Racket to C, ensuring the logic remains intact. | #lang racket
(display-to-file "" "output.txt")
(make-directory "docs")
(display-to-file "" "/output.txt")
(make-directory "/docs")
| #include <stdio.h>
int main() {
FILE *fh = fopen("output.txt", "w");
fclose(fh);
return 0;
}
|
Ensure the translated C# code behaves exactly like the original Racket snippet. | #lang racket
(display-to-file "" "output.txt")
(make-directory "docs")
(display-to-file "" "/output.txt")
(make-directory "/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");
}
}
|
Keep all operations the same but rewrite the snippet in C++. | #lang racket
(display-to-file "" "output.txt")
(make-directory "docs")
(display-to-file "" "/output.txt")
(make-directory "/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;
}
|
Port the provided Racket code into Java while preserving the original functionality. | #lang racket
(display-to-file "" "output.txt")
(make-directory "docs")
(display-to-file "" "/output.txt")
(make-directory "/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());
}
}
}
|
Produce a functionally identical Python code for the snippet given in Racket. | #lang racket
(display-to-file "" "output.txt")
(make-directory "docs")
(display-to-file "" "/output.txt")
(make-directory "/docs")
| import os
for directory in ['/', './']:
open(directory + 'output.txt', 'w').close()
os.mkdir(directory + 'docs')
|
Write the same code in VB as shown below in Racket. | #lang racket
(display-to-file "" "output.txt")
(make-directory "docs")
(display-to-file "" "/output.txt")
(make-directory "/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 programming language of this snippet from Racket to Go without modifying what it does. | #lang racket
(display-to-file "" "output.txt")
(make-directory "docs")
(display-to-file "" "/output.txt")
(make-directory "/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")
}
|
Please provide an equivalent version of this COBOL code in C. | identification division.
program-id. create-a-file.
data division.
working-storage section.
01 skip pic 9 value 2.
01 file-name.
05 value "/output.txt".
01 dir-name.
05 value "/docs".
01 file-handle usage binary-long.
procedure division.
files-main.
perform create-file-and-dir
move 1 to skip
perform create-file-and-dir
goback.
create-file-and-dir.
call "CBL_CREATE_FILE" using file-name(skip:) 3 0 0 file-handle
if return-code not equal 0 then
display "error: CBL_CREATE_FILE " file-name(skip:) ": "
file-handle ", " return-code upon syserr
end-if
call "CBL_CREATE_DIR" using dir-name(skip:)
if return-code not equal 0 then
display "error: CBL_CREATE_DIR " dir-name(skip:) ": "
return-code upon syserr
end-if
.
end program create-a-file.
| #include <stdio.h>
int main() {
FILE *fh = fopen("output.txt", "w");
fclose(fh);
return 0;
}
|
Rewrite this program in C# while keeping its functionality equivalent to the COBOL version. | identification division.
program-id. create-a-file.
data division.
working-storage section.
01 skip pic 9 value 2.
01 file-name.
05 value "/output.txt".
01 dir-name.
05 value "/docs".
01 file-handle usage binary-long.
procedure division.
files-main.
perform create-file-and-dir
move 1 to skip
perform create-file-and-dir
goback.
create-file-and-dir.
call "CBL_CREATE_FILE" using file-name(skip:) 3 0 0 file-handle
if return-code not equal 0 then
display "error: CBL_CREATE_FILE " file-name(skip:) ": "
file-handle ", " return-code upon syserr
end-if
call "CBL_CREATE_DIR" using dir-name(skip:)
if return-code not equal 0 then
display "error: CBL_CREATE_DIR " dir-name(skip:) ": "
return-code upon syserr
end-if
.
end program create-a-file.
| 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 the snippet below in C++ so it works the same as the original COBOL code. | identification division.
program-id. create-a-file.
data division.
working-storage section.
01 skip pic 9 value 2.
01 file-name.
05 value "/output.txt".
01 dir-name.
05 value "/docs".
01 file-handle usage binary-long.
procedure division.
files-main.
perform create-file-and-dir
move 1 to skip
perform create-file-and-dir
goback.
create-file-and-dir.
call "CBL_CREATE_FILE" using file-name(skip:) 3 0 0 file-handle
if return-code not equal 0 then
display "error: CBL_CREATE_FILE " file-name(skip:) ": "
file-handle ", " return-code upon syserr
end-if
call "CBL_CREATE_DIR" using dir-name(skip:)
if return-code not equal 0 then
display "error: CBL_CREATE_DIR " dir-name(skip:) ": "
return-code upon syserr
end-if
.
end program create-a-file.
| #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 COBOL function in Java with identical behavior. | identification division.
program-id. create-a-file.
data division.
working-storage section.
01 skip pic 9 value 2.
01 file-name.
05 value "/output.txt".
01 dir-name.
05 value "/docs".
01 file-handle usage binary-long.
procedure division.
files-main.
perform create-file-and-dir
move 1 to skip
perform create-file-and-dir
goback.
create-file-and-dir.
call "CBL_CREATE_FILE" using file-name(skip:) 3 0 0 file-handle
if return-code not equal 0 then
display "error: CBL_CREATE_FILE " file-name(skip:) ": "
file-handle ", " return-code upon syserr
end-if
call "CBL_CREATE_DIR" using dir-name(skip:)
if return-code not equal 0 then
display "error: CBL_CREATE_DIR " dir-name(skip:) ": "
return-code upon syserr
end-if
.
end program create-a-file.
| 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 COBOL code. | identification division.
program-id. create-a-file.
data division.
working-storage section.
01 skip pic 9 value 2.
01 file-name.
05 value "/output.txt".
01 dir-name.
05 value "/docs".
01 file-handle usage binary-long.
procedure division.
files-main.
perform create-file-and-dir
move 1 to skip
perform create-file-and-dir
goback.
create-file-and-dir.
call "CBL_CREATE_FILE" using file-name(skip:) 3 0 0 file-handle
if return-code not equal 0 then
display "error: CBL_CREATE_FILE " file-name(skip:) ": "
file-handle ", " return-code upon syserr
end-if
call "CBL_CREATE_DIR" using dir-name(skip:)
if return-code not equal 0 then
display "error: CBL_CREATE_DIR " dir-name(skip:) ": "
return-code upon syserr
end-if
.
end program create-a-file.
| import os
for directory in ['/', './']:
open(directory + 'output.txt', 'w').close()
os.mkdir(directory + 'docs')
|
Can you help me rewrite this code in VB instead of COBOL, keeping it the same logically? | identification division.
program-id. create-a-file.
data division.
working-storage section.
01 skip pic 9 value 2.
01 file-name.
05 value "/output.txt".
01 dir-name.
05 value "/docs".
01 file-handle usage binary-long.
procedure division.
files-main.
perform create-file-and-dir
move 1 to skip
perform create-file-and-dir
goback.
create-file-and-dir.
call "CBL_CREATE_FILE" using file-name(skip:) 3 0 0 file-handle
if return-code not equal 0 then
display "error: CBL_CREATE_FILE " file-name(skip:) ": "
file-handle ", " return-code upon syserr
end-if
call "CBL_CREATE_DIR" using dir-name(skip:)
if return-code not equal 0 then
display "error: CBL_CREATE_DIR " dir-name(skip:) ": "
return-code upon syserr
end-if
.
end program create-a-file.
| 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
|
Can you help me rewrite this code in Go instead of COBOL, keeping it the same logically? | identification division.
program-id. create-a-file.
data division.
working-storage section.
01 skip pic 9 value 2.
01 file-name.
05 value "/output.txt".
01 dir-name.
05 value "/docs".
01 file-handle usage binary-long.
procedure division.
files-main.
perform create-file-and-dir
move 1 to skip
perform create-file-and-dir
goback.
create-file-and-dir.
call "CBL_CREATE_FILE" using file-name(skip:) 3 0 0 file-handle
if return-code not equal 0 then
display "error: CBL_CREATE_FILE " file-name(skip:) ": "
file-handle ", " return-code upon syserr
end-if
call "CBL_CREATE_DIR" using dir-name(skip:)
if return-code not equal 0 then
display "error: CBL_CREATE_DIR " dir-name(skip:) ": "
return-code upon syserr
end-if
.
end program create-a-file.
| 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. |
options replace format comments java crossref symbols nobinary
fName = ''; fName[0] = 2; fName[1] = '.' || File.separator || 'output.txt'; fName[2] = File.separator || 'output.txt'
dName = ''; dName[0] = 2; dName[1] = '.' || File.separator || 'docs'; dName[2] = File.separator || 'docs'
do
loop i_ = 1 to fName[0]
say fName[i_]
fc = File(fName[i_]).createNewFile()
if fc then say 'File' fName[i_] 'created successfully.'
else say 'File' fName[i_] 'aleady exists.'
end i_
loop i_ = 1 to dName[0]
say dName[i_]
dc = File(dName[i_]).mkdir()
if dc then say 'Directory' dName[i_] 'created successfully.'
else say 'Directory' dName[i_] 'aleady exists.'
end i_
catch iox = IOException
iox.printStackTrace
end
return
| #include <stdio.h>
int main() {
FILE *fh = fopen("output.txt", "w");
fclose(fh);
return 0;
}
|
Maintain the same structure and functionality when rewriting this code in C#. |
options replace format comments java crossref symbols nobinary
fName = ''; fName[0] = 2; fName[1] = '.' || File.separator || 'output.txt'; fName[2] = File.separator || 'output.txt'
dName = ''; dName[0] = 2; dName[1] = '.' || File.separator || 'docs'; dName[2] = File.separator || 'docs'
do
loop i_ = 1 to fName[0]
say fName[i_]
fc = File(fName[i_]).createNewFile()
if fc then say 'File' fName[i_] 'created successfully.'
else say 'File' fName[i_] 'aleady exists.'
end i_
loop i_ = 1 to dName[0]
say dName[i_]
dc = File(dName[i_]).mkdir()
if dc then say 'Directory' dName[i_] 'created successfully.'
else say 'Directory' dName[i_] 'aleady exists.'
end i_
catch iox = IOException
iox.printStackTrace
end
return
| 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");
}
}
|
Maintain the same structure and functionality when rewriting this code in C++. |
options replace format comments java crossref symbols nobinary
fName = ''; fName[0] = 2; fName[1] = '.' || File.separator || 'output.txt'; fName[2] = File.separator || 'output.txt'
dName = ''; dName[0] = 2; dName[1] = '.' || File.separator || 'docs'; dName[2] = File.separator || 'docs'
do
loop i_ = 1 to fName[0]
say fName[i_]
fc = File(fName[i_]).createNewFile()
if fc then say 'File' fName[i_] 'created successfully.'
else say 'File' fName[i_] 'aleady exists.'
end i_
loop i_ = 1 to dName[0]
say dName[i_]
dc = File(dName[i_]).mkdir()
if dc then say 'Directory' dName[i_] 'created successfully.'
else say 'Directory' dName[i_] 'aleady exists.'
end i_
catch iox = IOException
iox.printStackTrace
end
return
| #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 REXX snippet to Java and keep its semantics consistent. |
options replace format comments java crossref symbols nobinary
fName = ''; fName[0] = 2; fName[1] = '.' || File.separator || 'output.txt'; fName[2] = File.separator || 'output.txt'
dName = ''; dName[0] = 2; dName[1] = '.' || File.separator || 'docs'; dName[2] = File.separator || 'docs'
do
loop i_ = 1 to fName[0]
say fName[i_]
fc = File(fName[i_]).createNewFile()
if fc then say 'File' fName[i_] 'created successfully.'
else say 'File' fName[i_] 'aleady exists.'
end i_
loop i_ = 1 to dName[0]
say dName[i_]
dc = File(dName[i_]).mkdir()
if dc then say 'Directory' dName[i_] 'created successfully.'
else say 'Directory' dName[i_] 'aleady exists.'
end i_
catch iox = IOException
iox.printStackTrace
end
return
| 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());
}
}
}
|
Please provide an equivalent version of this REXX code in Python. |
options replace format comments java crossref symbols nobinary
fName = ''; fName[0] = 2; fName[1] = '.' || File.separator || 'output.txt'; fName[2] = File.separator || 'output.txt'
dName = ''; dName[0] = 2; dName[1] = '.' || File.separator || 'docs'; dName[2] = File.separator || 'docs'
do
loop i_ = 1 to fName[0]
say fName[i_]
fc = File(fName[i_]).createNewFile()
if fc then say 'File' fName[i_] 'created successfully.'
else say 'File' fName[i_] 'aleady exists.'
end i_
loop i_ = 1 to dName[0]
say dName[i_]
dc = File(dName[i_]).mkdir()
if dc then say 'Directory' dName[i_] 'created successfully.'
else say 'Directory' dName[i_] 'aleady exists.'
end i_
catch iox = IOException
iox.printStackTrace
end
return
| import os
for directory in ['/', './']:
open(directory + 'output.txt', 'w').close()
os.mkdir(directory + 'docs')
|
Port the provided REXX code into VB while preserving the original functionality. |
options replace format comments java crossref symbols nobinary
fName = ''; fName[0] = 2; fName[1] = '.' || File.separator || 'output.txt'; fName[2] = File.separator || 'output.txt'
dName = ''; dName[0] = 2; dName[1] = '.' || File.separator || 'docs'; dName[2] = File.separator || 'docs'
do
loop i_ = 1 to fName[0]
say fName[i_]
fc = File(fName[i_]).createNewFile()
if fc then say 'File' fName[i_] 'created successfully.'
else say 'File' fName[i_] 'aleady exists.'
end i_
loop i_ = 1 to dName[0]
say dName[i_]
dc = File(dName[i_]).mkdir()
if dc then say 'Directory' dName[i_] 'created successfully.'
else say 'Directory' dName[i_] 'aleady exists.'
end i_
catch iox = IOException
iox.printStackTrace
end
return
| 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 REXX to Go, ensuring the logic remains intact. |
options replace format comments java crossref symbols nobinary
fName = ''; fName[0] = 2; fName[1] = '.' || File.separator || 'output.txt'; fName[2] = File.separator || 'output.txt'
dName = ''; dName[0] = 2; dName[1] = '.' || File.separator || 'docs'; dName[2] = File.separator || 'docs'
do
loop i_ = 1 to fName[0]
say fName[i_]
fc = File(fName[i_]).createNewFile()
if fc then say 'File' fName[i_] 'created successfully.'
else say 'File' fName[i_] 'aleady exists.'
end i_
loop i_ = 1 to dName[0]
say dName[i_]
dc = File(dName[i_]).mkdir()
if dc then say 'Directory' dName[i_] 'created successfully.'
else say 'Directory' dName[i_] 'aleady exists.'
end i_
catch iox = IOException
iox.printStackTrace
end
return
| 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 Ruby to C, ensuring the logic remains intact. | File.write "output.txt", ""
Dir.mkdir "docs"
File.write "/output.txt", ""
Dir.mkdir "/docs"
| #include <stdio.h>
int main() {
FILE *fh = fopen("output.txt", "w");
fclose(fh);
return 0;
}
|
Rewrite the snippet below in C# so it works the same as the original Ruby code. | File.write "output.txt", ""
Dir.mkdir "docs"
File.write "/output.txt", ""
Dir.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");
}
}
|
Write the same algorithm in C++ as shown in this Ruby implementation. | File.write "output.txt", ""
Dir.mkdir "docs"
File.write "/output.txt", ""
Dir.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;
}
|
Port the provided Ruby code into Java while preserving the original functionality. | File.write "output.txt", ""
Dir.mkdir "docs"
File.write "/output.txt", ""
Dir.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 Ruby block to Python, preserving its control flow and logic. | File.write "output.txt", ""
Dir.mkdir "docs"
File.write "/output.txt", ""
Dir.mkdir "/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 Ruby implementation. | File.write "output.txt", ""
Dir.mkdir "docs"
File.write "/output.txt", ""
Dir.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 Ruby to Go, ensuring the logic remains intact. | File.write "output.txt", ""
Dir.mkdir "docs"
File.write "/output.txt", ""
Dir.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")
}
|
Translate this program into C but keep the logic exactly as in Scala. |
import java.io.File
fun main(args: Array<String>) {
val filePaths = arrayOf("output.txt", "c:\\output.txt")
val dirPaths = arrayOf("docs", "c:\\docs")
var f: File
for (path in filePaths) {
f = File(path)
if (f.createNewFile())
println("$path successfully created")
else
println("$path already exists")
}
for (path in dirPaths) {
f = File(path)
if (f.mkdir())
println("$path successfully created")
else
println("$path already exists")
}
}
| #include <stdio.h>
int main() {
FILE *fh = fopen("output.txt", "w");
fclose(fh);
return 0;
}
|
Port the following code from Scala to C# with equivalent syntax and logic. |
import java.io.File
fun main(args: Array<String>) {
val filePaths = arrayOf("output.txt", "c:\\output.txt")
val dirPaths = arrayOf("docs", "c:\\docs")
var f: File
for (path in filePaths) {
f = File(path)
if (f.createNewFile())
println("$path successfully created")
else
println("$path already exists")
}
for (path in dirPaths) {
f = File(path)
if (f.mkdir())
println("$path successfully created")
else
println("$path already exists")
}
}
| 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");
}
}
|
Ensure the translated C++ code behaves exactly like the original Scala snippet. |
import java.io.File
fun main(args: Array<String>) {
val filePaths = arrayOf("output.txt", "c:\\output.txt")
val dirPaths = arrayOf("docs", "c:\\docs")
var f: File
for (path in filePaths) {
f = File(path)
if (f.createNewFile())
println("$path successfully created")
else
println("$path already exists")
}
for (path in dirPaths) {
f = File(path)
if (f.mkdir())
println("$path successfully created")
else
println("$path already exists")
}
}
| #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 Scala block to Java, preserving its control flow and logic. |
import java.io.File
fun main(args: Array<String>) {
val filePaths = arrayOf("output.txt", "c:\\output.txt")
val dirPaths = arrayOf("docs", "c:\\docs")
var f: File
for (path in filePaths) {
f = File(path)
if (f.createNewFile())
println("$path successfully created")
else
println("$path already exists")
}
for (path in dirPaths) {
f = File(path)
if (f.mkdir())
println("$path successfully created")
else
println("$path already exists")
}
}
| 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 Scala code snippet into Python without altering its behavior. |
import java.io.File
fun main(args: Array<String>) {
val filePaths = arrayOf("output.txt", "c:\\output.txt")
val dirPaths = arrayOf("docs", "c:\\docs")
var f: File
for (path in filePaths) {
f = File(path)
if (f.createNewFile())
println("$path successfully created")
else
println("$path already exists")
}
for (path in dirPaths) {
f = File(path)
if (f.mkdir())
println("$path successfully created")
else
println("$path already exists")
}
}
| import os
for directory in ['/', './']:
open(directory + 'output.txt', 'w').close()
os.mkdir(directory + 'docs')
|
Please provide an equivalent version of this Scala code in VB. |
import java.io.File
fun main(args: Array<String>) {
val filePaths = arrayOf("output.txt", "c:\\output.txt")
val dirPaths = arrayOf("docs", "c:\\docs")
var f: File
for (path in filePaths) {
f = File(path)
if (f.createNewFile())
println("$path successfully created")
else
println("$path already exists")
}
for (path in dirPaths) {
f = File(path)
if (f.mkdir())
println("$path successfully created")
else
println("$path already exists")
}
}
| 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 Scala block to Go, preserving its control flow and logic. |
import java.io.File
fun main(args: Array<String>) {
val filePaths = arrayOf("output.txt", "c:\\output.txt")
val dirPaths = arrayOf("docs", "c:\\docs")
var f: File
for (path in filePaths) {
f = File(path)
if (f.createNewFile())
println("$path successfully created")
else
println("$path already exists")
}
for (path in dirPaths) {
f = File(path)
if (f.mkdir())
println("$path successfully created")
else
println("$path already exists")
}
}
| 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")
}
|
Write a version of this Tcl function in C with identical behavior. | close [open output.txt w]
close [open [file nativename /output.txt] w]
file mkdir docs
file mkdir [file nativename /docs]
| #include <stdio.h>
int main() {
FILE *fh = fopen("output.txt", "w");
fclose(fh);
return 0;
}
|
Maintain the same structure and functionality when rewriting this code in C#. | close [open output.txt w]
close [open [file nativename /output.txt] w]
file mkdir docs
file mkdir [file nativename /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 the given Tcl code snippet into C++ without altering its behavior. | close [open output.txt w]
close [open [file nativename /output.txt] w]
file mkdir docs
file mkdir [file nativename /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;
}
|
Convert this Tcl block to Java, preserving its control flow and logic. | close [open output.txt w]
close [open [file nativename /output.txt] w]
file mkdir docs
file mkdir [file nativename /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 Tcl snippet to Python and keep its semantics consistent. | close [open output.txt w]
close [open [file nativename /output.txt] w]
file mkdir docs
file mkdir [file nativename /docs]
| import os
for directory in ['/', './']:
open(directory + 'output.txt', 'w').close()
os.mkdir(directory + 'docs')
|
Generate an equivalent VB version of this Tcl code. | close [open output.txt w]
close [open [file nativename /output.txt] w]
file mkdir docs
file mkdir [file nativename /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 programming language of this snippet from Tcl to Go without modifying what it does. | close [open output.txt w]
close [open [file nativename /output.txt] w]
file mkdir docs
file mkdir [file nativename /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 following Rust code into PHP without altering its purpose. | use std::io::{self, Write};
use std::fs::{DirBuilder, File};
use std::path::Path;
use std::{process,fmt};
const FILE_NAME: &'static str = "output.txt";
const DIR_NAME : &'static str = "docs";
fn main() {
create(".").and(create("/"))
.unwrap_or_else(|e| error_handler(e,1));
}
fn create<P>(root: P) -> io::Result<File>
where P: AsRef<Path>
{
let f_path = root.as_ref().join(FILE_NAME);
let d_path = root.as_ref().join(DIR_NAME);
DirBuilder::new().create(d_path).and(File::create(f_path))
}
fn error_handler<E: fmt::Display>(error: E, code: i32) -> ! {
let _ = writeln!(&mut io::stderr(), "Error: {}", error);
process::exit(code)
}
| <?php
touch('output.txt');
mkdir('docs');
touch('/output.txt');
mkdir('/docs');
?>
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.