Instruction
stringlengths
45
106
input_code
stringlengths
1
13.7k
output_code
stringlengths
1
13.7k
Generate a C# translation of this Clojure snippet without changing its computational steps.
(slurp "myfile.txt") (slurp "my-utf8-file.txt" "UTF-8")
using System.IO; class Program { static void Main(string[] args) { var fileContents = File.ReadAllText("c:\\autoexec.bat"); } }
Transform the following Clojure implementation into C++, maintaining the same output and logic.
(slurp "myfile.txt") (slurp "my-utf8-file.txt" "UTF-8")
#include <iostream> #include <fstream> #include <string> #include <iterator> int main( ) { if (std::ifstream infile("sample.txt")) { std::string fileData(std::istreambuf_iterator<char>(infile), std::istreambuf_iterator<char>()); cout << "File has " << fileData.size() << "chars\n"; return 0; } else { std::cout << "file not found!\n"; return 1; } }
Produce a functionally identical Java code for the snippet given in Clojure.
(slurp "myfile.txt") (slurp "my-utf8-file.txt" "UTF-8")
static Byte[] contentsOf(File file) { return file.contents; }
Generate a VB translation of this Clojure snippet without changing its computational steps.
(slurp "myfile.txt") (slurp "my-utf8-file.txt" "UTF-8")
dim s s = createobject("scripting.filesystemobject").opentextfile("slurp.vbs",1).readall wscript.echo s
Generate an equivalent Go version of this Clojure code.
(slurp "myfile.txt") (slurp "my-utf8-file.txt" "UTF-8")
import "io/ioutil" data, err := ioutil.ReadFile(filename) sv := string(data)
Rewrite the snippet below in C so it works the same as the original Common_Lisp code.
(defun file-string (path) (with-open-file (stream path) (let ((data (make-string (file-length stream)))) (read-sequence data stream) data)))
#include <stdio.h> #include <stdlib.h> int main() { char *buffer; FILE *fh = fopen("readentirefile.c", "rb"); if ( fh != NULL ) { fseek(fh, 0L, SEEK_END); long s = ftell(fh); rewind(fh); buffer = malloc(s); if ( buffer != NULL ) { fread(buffer, s, 1, fh); fclose(fh); fh = NULL; fwrite(buffer, s, 1, stdout); free(buffer); } if (fh != NULL) fclose(fh); } return EXIT_SUCCESS; }
Convert the following code from Common_Lisp to C#, ensuring the logic remains intact.
(defun file-string (path) (with-open-file (stream path) (let ((data (make-string (file-length stream)))) (read-sequence data stream) data)))
using System.IO; class Program { static void Main(string[] args) { var fileContents = File.ReadAllText("c:\\autoexec.bat"); } }
Keep all operations the same but rewrite the snippet in C++.
(defun file-string (path) (with-open-file (stream path) (let ((data (make-string (file-length stream)))) (read-sequence data stream) data)))
#include <iostream> #include <fstream> #include <string> #include <iterator> int main( ) { if (std::ifstream infile("sample.txt")) { std::string fileData(std::istreambuf_iterator<char>(infile), std::istreambuf_iterator<char>()); cout << "File has " << fileData.size() << "chars\n"; return 0; } else { std::cout << "file not found!\n"; return 1; } }
Rewrite this program in Java while keeping its functionality equivalent to the Common_Lisp version.
(defun file-string (path) (with-open-file (stream path) (let ((data (make-string (file-length stream)))) (read-sequence data stream) data)))
static Byte[] contentsOf(File file) { return file.contents; }
Produce a language-to-language conversion: from Common_Lisp to Python, same semantics.
(defun file-string (path) (with-open-file (stream path) (let ((data (make-string (file-length stream)))) (read-sequence data stream) data)))
open(filename).read()
Generate an equivalent VB version of this Common_Lisp code.
(defun file-string (path) (with-open-file (stream path) (let ((data (make-string (file-length stream)))) (read-sequence data stream) data)))
dim s s = createobject("scripting.filesystemobject").opentextfile("slurp.vbs",1).readall wscript.echo s
Port the following code from Common_Lisp to Go with equivalent syntax and logic.
(defun file-string (path) (with-open-file (stream path) (let ((data (make-string (file-length stream)))) (read-sequence data stream) data)))
import "io/ioutil" data, err := ioutil.ReadFile(filename) sv := string(data)
Convert this D block to C, preserving its control flow and logic.
import std.file: read, readText; void main() { auto data = cast(ubyte[])read("unixdict.txt"); string txt = readText("unixdict.txt"); }
#include <stdio.h> #include <stdlib.h> int main() { char *buffer; FILE *fh = fopen("readentirefile.c", "rb"); if ( fh != NULL ) { fseek(fh, 0L, SEEK_END); long s = ftell(fh); rewind(fh); buffer = malloc(s); if ( buffer != NULL ) { fread(buffer, s, 1, fh); fclose(fh); fh = NULL; fwrite(buffer, s, 1, stdout); free(buffer); } if (fh != NULL) fclose(fh); } return EXIT_SUCCESS; }
Convert the following code from D to C#, ensuring the logic remains intact.
import std.file: read, readText; void main() { auto data = cast(ubyte[])read("unixdict.txt"); string txt = readText("unixdict.txt"); }
using System.IO; class Program { static void Main(string[] args) { var fileContents = File.ReadAllText("c:\\autoexec.bat"); } }
Produce a language-to-language conversion: from D to C++, same semantics.
import std.file: read, readText; void main() { auto data = cast(ubyte[])read("unixdict.txt"); string txt = readText("unixdict.txt"); }
#include <iostream> #include <fstream> #include <string> #include <iterator> int main( ) { if (std::ifstream infile("sample.txt")) { std::string fileData(std::istreambuf_iterator<char>(infile), std::istreambuf_iterator<char>()); cout << "File has " << fileData.size() << "chars\n"; return 0; } else { std::cout << "file not found!\n"; return 1; } }
Rewrite the snippet below in Java so it works the same as the original D code.
import std.file: read, readText; void main() { auto data = cast(ubyte[])read("unixdict.txt"); string txt = readText("unixdict.txt"); }
static Byte[] contentsOf(File file) { return file.contents; }
Generate a Python translation of this D snippet without changing its computational steps.
import std.file: read, readText; void main() { auto data = cast(ubyte[])read("unixdict.txt"); string txt = readText("unixdict.txt"); }
open(filename).read()
Produce a functionally identical VB code for the snippet given in D.
import std.file: read, readText; void main() { auto data = cast(ubyte[])read("unixdict.txt"); string txt = readText("unixdict.txt"); }
dim s s = createobject("scripting.filesystemobject").opentextfile("slurp.vbs",1).readall wscript.echo s
Transform the following D implementation into Go, maintaining the same output and logic.
import std.file: read, readText; void main() { auto data = cast(ubyte[])read("unixdict.txt"); string txt = readText("unixdict.txt"); }
import "io/ioutil" data, err := ioutil.ReadFile(filename) sv := string(data)
Change the programming language of this snippet from Delphi to C without modifying what it does.
program ReadAll; uses Classes; var i: Integer; lList: TStringList; begin lList := TStringList.Create; try lList.LoadFromFile('c:\input.txt'); Writeln(lList.Text); for i := 0 to lList.Count - 1 do Writeln(lList[i]); finally lList.Free; end; end.
#include <stdio.h> #include <stdlib.h> int main() { char *buffer; FILE *fh = fopen("readentirefile.c", "rb"); if ( fh != NULL ) { fseek(fh, 0L, SEEK_END); long s = ftell(fh); rewind(fh); buffer = malloc(s); if ( buffer != NULL ) { fread(buffer, s, 1, fh); fclose(fh); fh = NULL; fwrite(buffer, s, 1, stdout); free(buffer); } if (fh != NULL) fclose(fh); } return EXIT_SUCCESS; }
Generate a C# translation of this Delphi snippet without changing its computational steps.
program ReadAll; uses Classes; var i: Integer; lList: TStringList; begin lList := TStringList.Create; try lList.LoadFromFile('c:\input.txt'); Writeln(lList.Text); for i := 0 to lList.Count - 1 do Writeln(lList[i]); finally lList.Free; end; end.
using System.IO; class Program { static void Main(string[] args) { var fileContents = File.ReadAllText("c:\\autoexec.bat"); } }
Rewrite this program in C++ while keeping its functionality equivalent to the Delphi version.
program ReadAll; uses Classes; var i: Integer; lList: TStringList; begin lList := TStringList.Create; try lList.LoadFromFile('c:\input.txt'); Writeln(lList.Text); for i := 0 to lList.Count - 1 do Writeln(lList[i]); finally lList.Free; end; end.
#include <iostream> #include <fstream> #include <string> #include <iterator> int main( ) { if (std::ifstream infile("sample.txt")) { std::string fileData(std::istreambuf_iterator<char>(infile), std::istreambuf_iterator<char>()); cout << "File has " << fileData.size() << "chars\n"; return 0; } else { std::cout << "file not found!\n"; return 1; } }
Preserve the algorithm and functionality while converting the code from Delphi to Java.
program ReadAll; uses Classes; var i: Integer; lList: TStringList; begin lList := TStringList.Create; try lList.LoadFromFile('c:\input.txt'); Writeln(lList.Text); for i := 0 to lList.Count - 1 do Writeln(lList[i]); finally lList.Free; end; end.
static Byte[] contentsOf(File file) { return file.contents; }
Change the programming language of this snippet from Delphi to Python without modifying what it does.
program ReadAll; uses Classes; var i: Integer; lList: TStringList; begin lList := TStringList.Create; try lList.LoadFromFile('c:\input.txt'); Writeln(lList.Text); for i := 0 to lList.Count - 1 do Writeln(lList[i]); finally lList.Free; end; end.
open(filename).read()
Can you help me rewrite this code in VB instead of Delphi, keeping it the same logically?
program ReadAll; uses Classes; var i: Integer; lList: TStringList; begin lList := TStringList.Create; try lList.LoadFromFile('c:\input.txt'); Writeln(lList.Text); for i := 0 to lList.Count - 1 do Writeln(lList[i]); finally lList.Free; end; end.
dim s s = createobject("scripting.filesystemobject").opentextfile("slurp.vbs",1).readall wscript.echo s
Keep all operations the same but rewrite the snippet in Go.
program ReadAll; uses Classes; var i: Integer; lList: TStringList; begin lList := TStringList.Create; try lList.LoadFromFile('c:\input.txt'); Writeln(lList.Text); for i := 0 to lList.Count - 1 do Writeln(lList[i]); finally lList.Free; end; end.
import "io/ioutil" data, err := ioutil.ReadFile(filename) sv := string(data)
Generate an equivalent C version of this Elixir code.
defmodule FileReader do def read(path) do case File.read(path) do {:ok, body} -> IO.inspect body {:error,reason} -> :file.format_error(reason) end end def bit_read(path) do case File.open(path) do {:ok, file} -> IO.read(file,:all) |> IO.inspect {:error,reason} -> :file.format_error(reason) end end end
#include <stdio.h> #include <stdlib.h> int main() { char *buffer; FILE *fh = fopen("readentirefile.c", "rb"); if ( fh != NULL ) { fseek(fh, 0L, SEEK_END); long s = ftell(fh); rewind(fh); buffer = malloc(s); if ( buffer != NULL ) { fread(buffer, s, 1, fh); fclose(fh); fh = NULL; fwrite(buffer, s, 1, stdout); free(buffer); } if (fh != NULL) fclose(fh); } return EXIT_SUCCESS; }
Produce a functionally identical C# code for the snippet given in Elixir.
defmodule FileReader do def read(path) do case File.read(path) do {:ok, body} -> IO.inspect body {:error,reason} -> :file.format_error(reason) end end def bit_read(path) do case File.open(path) do {:ok, file} -> IO.read(file,:all) |> IO.inspect {:error,reason} -> :file.format_error(reason) end end end
using System.IO; class Program { static void Main(string[] args) { var fileContents = File.ReadAllText("c:\\autoexec.bat"); } }
Convert the following code from Elixir to C++, ensuring the logic remains intact.
defmodule FileReader do def read(path) do case File.read(path) do {:ok, body} -> IO.inspect body {:error,reason} -> :file.format_error(reason) end end def bit_read(path) do case File.open(path) do {:ok, file} -> IO.read(file,:all) |> IO.inspect {:error,reason} -> :file.format_error(reason) end end end
#include <iostream> #include <fstream> #include <string> #include <iterator> int main( ) { if (std::ifstream infile("sample.txt")) { std::string fileData(std::istreambuf_iterator<char>(infile), std::istreambuf_iterator<char>()); cout << "File has " << fileData.size() << "chars\n"; return 0; } else { std::cout << "file not found!\n"; return 1; } }
Port the provided Elixir code into Java while preserving the original functionality.
defmodule FileReader do def read(path) do case File.read(path) do {:ok, body} -> IO.inspect body {:error,reason} -> :file.format_error(reason) end end def bit_read(path) do case File.open(path) do {:ok, file} -> IO.read(file,:all) |> IO.inspect {:error,reason} -> :file.format_error(reason) end end end
static Byte[] contentsOf(File file) { return file.contents; }
Convert this Elixir snippet to Python and keep its semantics consistent.
defmodule FileReader do def read(path) do case File.read(path) do {:ok, body} -> IO.inspect body {:error,reason} -> :file.format_error(reason) end end def bit_read(path) do case File.open(path) do {:ok, file} -> IO.read(file,:all) |> IO.inspect {:error,reason} -> :file.format_error(reason) end end end
open(filename).read()
Write a version of this Elixir function in VB with identical behavior.
defmodule FileReader do def read(path) do case File.read(path) do {:ok, body} -> IO.inspect body {:error,reason} -> :file.format_error(reason) end end def bit_read(path) do case File.open(path) do {:ok, file} -> IO.read(file,:all) |> IO.inspect {:error,reason} -> :file.format_error(reason) end end end
dim s s = createobject("scripting.filesystemobject").opentextfile("slurp.vbs",1).readall wscript.echo s
Can you help me rewrite this code in Go instead of Elixir, keeping it the same logically?
defmodule FileReader do def read(path) do case File.read(path) do {:ok, body} -> IO.inspect body {:error,reason} -> :file.format_error(reason) end end def bit_read(path) do case File.open(path) do {:ok, file} -> IO.read(file,:all) |> IO.inspect {:error,reason} -> :file.format_error(reason) end end end
import "io/ioutil" data, err := ioutil.ReadFile(filename) sv := string(data)
Write the same code in C as shown below in Erlang.
{ok, B} = file:read_file("myfile.txt").
#include <stdio.h> #include <stdlib.h> int main() { char *buffer; FILE *fh = fopen("readentirefile.c", "rb"); if ( fh != NULL ) { fseek(fh, 0L, SEEK_END); long s = ftell(fh); rewind(fh); buffer = malloc(s); if ( buffer != NULL ) { fread(buffer, s, 1, fh); fclose(fh); fh = NULL; fwrite(buffer, s, 1, stdout); free(buffer); } if (fh != NULL) fclose(fh); } return EXIT_SUCCESS; }
Convert this Erlang snippet to C# and keep its semantics consistent.
{ok, B} = file:read_file("myfile.txt").
using System.IO; class Program { static void Main(string[] args) { var fileContents = File.ReadAllText("c:\\autoexec.bat"); } }
Generate an equivalent C++ version of this Erlang code.
{ok, B} = file:read_file("myfile.txt").
#include <iostream> #include <fstream> #include <string> #include <iterator> int main( ) { if (std::ifstream infile("sample.txt")) { std::string fileData(std::istreambuf_iterator<char>(infile), std::istreambuf_iterator<char>()); cout << "File has " << fileData.size() << "chars\n"; return 0; } else { std::cout << "file not found!\n"; return 1; } }
Convert the following code from Erlang to Java, ensuring the logic remains intact.
{ok, B} = file:read_file("myfile.txt").
static Byte[] contentsOf(File file) { return file.contents; }
Produce a language-to-language conversion: from Erlang to VB, same semantics.
{ok, B} = file:read_file("myfile.txt").
dim s s = createobject("scripting.filesystemobject").opentextfile("slurp.vbs",1).readall wscript.echo s
Change the following Erlang code into Go without altering its purpose.
{ok, B} = file:read_file("myfile.txt").
import "io/ioutil" data, err := ioutil.ReadFile(filename) sv := string(data)
Port the following code from F# to C with equivalent syntax and logic.
open System.IO let data = File.ReadAllText(filename) let utf8 = File.ReadAllText(filename, System.Text.Encoding.UTF8)
#include <stdio.h> #include <stdlib.h> int main() { char *buffer; FILE *fh = fopen("readentirefile.c", "rb"); if ( fh != NULL ) { fseek(fh, 0L, SEEK_END); long s = ftell(fh); rewind(fh); buffer = malloc(s); if ( buffer != NULL ) { fread(buffer, s, 1, fh); fclose(fh); fh = NULL; fwrite(buffer, s, 1, stdout); free(buffer); } if (fh != NULL) fclose(fh); } return EXIT_SUCCESS; }
Generate a C# translation of this F# snippet without changing its computational steps.
open System.IO let data = File.ReadAllText(filename) let utf8 = File.ReadAllText(filename, System.Text.Encoding.UTF8)
using System.IO; class Program { static void Main(string[] args) { var fileContents = File.ReadAllText("c:\\autoexec.bat"); } }
Convert this F# snippet to C++ and keep its semantics consistent.
open System.IO let data = File.ReadAllText(filename) let utf8 = File.ReadAllText(filename, System.Text.Encoding.UTF8)
#include <iostream> #include <fstream> #include <string> #include <iterator> int main( ) { if (std::ifstream infile("sample.txt")) { std::string fileData(std::istreambuf_iterator<char>(infile), std::istreambuf_iterator<char>()); cout << "File has " << fileData.size() << "chars\n"; return 0; } else { std::cout << "file not found!\n"; return 1; } }
Can you help me rewrite this code in Java instead of F#, keeping it the same logically?
open System.IO let data = File.ReadAllText(filename) let utf8 = File.ReadAllText(filename, System.Text.Encoding.UTF8)
static Byte[] contentsOf(File file) { return file.contents; }
Maintain the same structure and functionality when rewriting this code in Python.
open System.IO let data = File.ReadAllText(filename) let utf8 = File.ReadAllText(filename, System.Text.Encoding.UTF8)
open(filename).read()
Rewrite the snippet below in VB so it works the same as the original F# code.
open System.IO let data = File.ReadAllText(filename) let utf8 = File.ReadAllText(filename, System.Text.Encoding.UTF8)
dim s s = createobject("scripting.filesystemobject").opentextfile("slurp.vbs",1).readall wscript.echo s
Translate this program into Go but keep the logic exactly as in F#.
open System.IO let data = File.ReadAllText(filename) let utf8 = File.ReadAllText(filename, System.Text.Encoding.UTF8)
import "io/ioutil" data, err := ioutil.ReadFile(filename) sv := string(data)
Maintain the same structure and functionality when rewriting this code in C.
USING: io.encodings.ascii io.encodings.binary io.files ; "foo.txt" binary file-contents "foo.txt" ascii file-lines
#include <stdio.h> #include <stdlib.h> int main() { char *buffer; FILE *fh = fopen("readentirefile.c", "rb"); if ( fh != NULL ) { fseek(fh, 0L, SEEK_END); long s = ftell(fh); rewind(fh); buffer = malloc(s); if ( buffer != NULL ) { fread(buffer, s, 1, fh); fclose(fh); fh = NULL; fwrite(buffer, s, 1, stdout); free(buffer); } if (fh != NULL) fclose(fh); } return EXIT_SUCCESS; }
Change the programming language of this snippet from Factor to C# without modifying what it does.
USING: io.encodings.ascii io.encodings.binary io.files ; "foo.txt" binary file-contents "foo.txt" ascii file-lines
using System.IO; class Program { static void Main(string[] args) { var fileContents = File.ReadAllText("c:\\autoexec.bat"); } }
Rewrite the snippet below in C++ so it works the same as the original Factor code.
USING: io.encodings.ascii io.encodings.binary io.files ; "foo.txt" binary file-contents "foo.txt" ascii file-lines
#include <iostream> #include <fstream> #include <string> #include <iterator> int main( ) { if (std::ifstream infile("sample.txt")) { std::string fileData(std::istreambuf_iterator<char>(infile), std::istreambuf_iterator<char>()); cout << "File has " << fileData.size() << "chars\n"; return 0; } else { std::cout << "file not found!\n"; return 1; } }
Rewrite the snippet below in Java so it works the same as the original Factor code.
USING: io.encodings.ascii io.encodings.binary io.files ; "foo.txt" binary file-contents "foo.txt" ascii file-lines
static Byte[] contentsOf(File file) { return file.contents; }
Write the same algorithm in Python as shown in this Factor implementation.
USING: io.encodings.ascii io.encodings.binary io.files ; "foo.txt" binary file-contents "foo.txt" ascii file-lines
open(filename).read()
Preserve the algorithm and functionality while converting the code from Factor to VB.
USING: io.encodings.ascii io.encodings.binary io.files ; "foo.txt" binary file-contents "foo.txt" ascii file-lines
dim s s = createobject("scripting.filesystemobject").opentextfile("slurp.vbs",1).readall wscript.echo s
Maintain the same structure and functionality when rewriting this code in Go.
USING: io.encodings.ascii io.encodings.binary io.files ; "foo.txt" binary file-contents "foo.txt" ascii file-lines
import "io/ioutil" data, err := ioutil.ReadFile(filename) sv := string(data)
Port the provided Forth code into C while preserving the original functionality.
"somefile.txt" f:slurp >s
#include <stdio.h> #include <stdlib.h> int main() { char *buffer; FILE *fh = fopen("readentirefile.c", "rb"); if ( fh != NULL ) { fseek(fh, 0L, SEEK_END); long s = ftell(fh); rewind(fh); buffer = malloc(s); if ( buffer != NULL ) { fread(buffer, s, 1, fh); fclose(fh); fh = NULL; fwrite(buffer, s, 1, stdout); free(buffer); } if (fh != NULL) fclose(fh); } return EXIT_SUCCESS; }
Write the same code in C# as shown below in Forth.
"somefile.txt" f:slurp >s
using System.IO; class Program { static void Main(string[] args) { var fileContents = File.ReadAllText("c:\\autoexec.bat"); } }
Produce a language-to-language conversion: from Forth to C++, same semantics.
"somefile.txt" f:slurp >s
#include <iostream> #include <fstream> #include <string> #include <iterator> int main( ) { if (std::ifstream infile("sample.txt")) { std::string fileData(std::istreambuf_iterator<char>(infile), std::istreambuf_iterator<char>()); cout << "File has " << fileData.size() << "chars\n"; return 0; } else { std::cout << "file not found!\n"; return 1; } }
Write a version of this Forth function in VB with identical behavior.
"somefile.txt" f:slurp >s
dim s s = createobject("scripting.filesystemobject").opentextfile("slurp.vbs",1).readall wscript.echo s
Write the same algorithm in Go as shown in this Forth implementation.
"somefile.txt" f:slurp >s
import "io/ioutil" data, err := ioutil.ReadFile(filename) sv := string(data)
Write a version of this Fortran function in C# with identical behavior.
program read_file implicit none integer :: n character(:), allocatable :: s open(unit=10, file="read_file.f90", action="read", & form="unformatted", access="stream") inquire(unit=10, size=n) allocate(character(n) :: s) read(10) s close(10) print "(A)", s end program
using System.IO; class Program { static void Main(string[] args) { var fileContents = File.ReadAllText("c:\\autoexec.bat"); } }
Generate an equivalent C++ version of this Fortran code.
program read_file implicit none integer :: n character(:), allocatable :: s open(unit=10, file="read_file.f90", action="read", & form="unformatted", access="stream") inquire(unit=10, size=n) allocate(character(n) :: s) read(10) s close(10) print "(A)", s end program
#include <iostream> #include <fstream> #include <string> #include <iterator> int main( ) { if (std::ifstream infile("sample.txt")) { std::string fileData(std::istreambuf_iterator<char>(infile), std::istreambuf_iterator<char>()); cout << "File has " << fileData.size() << "chars\n"; return 0; } else { std::cout << "file not found!\n"; return 1; } }
Rewrite the snippet below in C so it works the same as the original Fortran code.
program read_file implicit none integer :: n character(:), allocatable :: s open(unit=10, file="read_file.f90", action="read", & form="unformatted", access="stream") inquire(unit=10, size=n) allocate(character(n) :: s) read(10) s close(10) print "(A)", s end program
#include <stdio.h> #include <stdlib.h> int main() { char *buffer; FILE *fh = fopen("readentirefile.c", "rb"); if ( fh != NULL ) { fseek(fh, 0L, SEEK_END); long s = ftell(fh); rewind(fh); buffer = malloc(s); if ( buffer != NULL ) { fread(buffer, s, 1, fh); fclose(fh); fh = NULL; fwrite(buffer, s, 1, stdout); free(buffer); } if (fh != NULL) fclose(fh); } return EXIT_SUCCESS; }
Convert this Fortran snippet to Java and keep its semantics consistent.
program read_file implicit none integer :: n character(:), allocatable :: s open(unit=10, file="read_file.f90", action="read", & form="unformatted", access="stream") inquire(unit=10, size=n) allocate(character(n) :: s) read(10) s close(10) print "(A)", s end program
static Byte[] contentsOf(File file) { return file.contents; }
Port the following code from Fortran to Python with equivalent syntax and logic.
program read_file implicit none integer :: n character(:), allocatable :: s open(unit=10, file="read_file.f90", action="read", & form="unformatted", access="stream") inquire(unit=10, size=n) allocate(character(n) :: s) read(10) s close(10) print "(A)", s end program
open(filename).read()
Ensure the translated VB code behaves exactly like the original Fortran snippet.
program read_file implicit none integer :: n character(:), allocatable :: s open(unit=10, file="read_file.f90", action="read", & form="unformatted", access="stream") inquire(unit=10, size=n) allocate(character(n) :: s) read(10) s close(10) print "(A)", s end program
dim s s = createobject("scripting.filesystemobject").opentextfile("slurp.vbs",1).readall wscript.echo s
Translate the given Fortran code snippet into PHP without altering its behavior.
program read_file implicit none integer :: n character(:), allocatable :: s open(unit=10, file="read_file.f90", action="read", & form="unformatted", access="stream") inquire(unit=10, size=n) allocate(character(n) :: s) read(10) s close(10) print "(A)", s end program
file_get_contents($filename)
Write a version of this Groovy function in C with identical behavior.
def fileContent = new File("c:\\file.txt").text
#include <stdio.h> #include <stdlib.h> int main() { char *buffer; FILE *fh = fopen("readentirefile.c", "rb"); if ( fh != NULL ) { fseek(fh, 0L, SEEK_END); long s = ftell(fh); rewind(fh); buffer = malloc(s); if ( buffer != NULL ) { fread(buffer, s, 1, fh); fclose(fh); fh = NULL; fwrite(buffer, s, 1, stdout); free(buffer); } if (fh != NULL) fclose(fh); } return EXIT_SUCCESS; }
Please provide an equivalent version of this Groovy code in C#.
def fileContent = new File("c:\\file.txt").text
using System.IO; class Program { static void Main(string[] args) { var fileContents = File.ReadAllText("c:\\autoexec.bat"); } }
Generate a C++ translation of this Groovy snippet without changing its computational steps.
def fileContent = new File("c:\\file.txt").text
#include <iostream> #include <fstream> #include <string> #include <iterator> int main( ) { if (std::ifstream infile("sample.txt")) { std::string fileData(std::istreambuf_iterator<char>(infile), std::istreambuf_iterator<char>()); cout << "File has " << fileData.size() << "chars\n"; return 0; } else { std::cout << "file not found!\n"; return 1; } }
Keep all operations the same but rewrite the snippet in VB.
def fileContent = new File("c:\\file.txt").text
dim s s = createobject("scripting.filesystemobject").opentextfile("slurp.vbs",1).readall wscript.echo s
Transform the following Groovy implementation into Go, maintaining the same output and logic.
def fileContent = new File("c:\\file.txt").text
import "io/ioutil" data, err := ioutil.ReadFile(filename) sv := string(data)
Translate the given Haskell code snippet into C without altering its behavior.
do text <- readFile filepath
#include <stdio.h> #include <stdlib.h> int main() { char *buffer; FILE *fh = fopen("readentirefile.c", "rb"); if ( fh != NULL ) { fseek(fh, 0L, SEEK_END); long s = ftell(fh); rewind(fh); buffer = malloc(s); if ( buffer != NULL ) { fread(buffer, s, 1, fh); fclose(fh); fh = NULL; fwrite(buffer, s, 1, stdout); free(buffer); } if (fh != NULL) fclose(fh); } return EXIT_SUCCESS; }
Can you help me rewrite this code in C# instead of Haskell, keeping it the same logically?
do text <- readFile filepath
using System.IO; class Program { static void Main(string[] args) { var fileContents = File.ReadAllText("c:\\autoexec.bat"); } }
Write the same algorithm in C++ as shown in this Haskell implementation.
do text <- readFile filepath
#include <iostream> #include <fstream> #include <string> #include <iterator> int main( ) { if (std::ifstream infile("sample.txt")) { std::string fileData(std::istreambuf_iterator<char>(infile), std::istreambuf_iterator<char>()); cout << "File has " << fileData.size() << "chars\n"; return 0; } else { std::cout << "file not found!\n"; return 1; } }
Can you help me rewrite this code in VB instead of Haskell, keeping it the same logically?
do text <- readFile filepath
dim s s = createobject("scripting.filesystemobject").opentextfile("slurp.vbs",1).readall wscript.echo s
Port the provided Icon code into C while preserving the original functionality.
every (fs := "") ||:= |reads(1000000)
#include <stdio.h> #include <stdlib.h> int main() { char *buffer; FILE *fh = fopen("readentirefile.c", "rb"); if ( fh != NULL ) { fseek(fh, 0L, SEEK_END); long s = ftell(fh); rewind(fh); buffer = malloc(s); if ( buffer != NULL ) { fread(buffer, s, 1, fh); fclose(fh); fh = NULL; fwrite(buffer, s, 1, stdout); free(buffer); } if (fh != NULL) fclose(fh); } return EXIT_SUCCESS; }
Write a version of this Icon function in C# with identical behavior.
every (fs := "") ||:= |reads(1000000)
using System.IO; class Program { static void Main(string[] args) { var fileContents = File.ReadAllText("c:\\autoexec.bat"); } }
Rewrite the snippet below in C++ so it works the same as the original Icon code.
every (fs := "") ||:= |reads(1000000)
#include <iostream> #include <fstream> #include <string> #include <iterator> int main( ) { if (std::ifstream infile("sample.txt")) { std::string fileData(std::istreambuf_iterator<char>(infile), std::istreambuf_iterator<char>()); cout << "File has " << fileData.size() << "chars\n"; return 0; } else { std::cout << "file not found!\n"; return 1; } }
Can you help me rewrite this code in Java instead of Icon, keeping it the same logically?
every (fs := "") ||:= |reads(1000000)
static Byte[] contentsOf(File file) { return file.contents; }
Generate a VB translation of this Icon snippet without changing its computational steps.
every (fs := "") ||:= |reads(1000000)
dim s s = createobject("scripting.filesystemobject").opentextfile("slurp.vbs",1).readall wscript.echo s
Rewrite the snippet below in Go so it works the same as the original Icon code.
every (fs := "") ||:= |reads(1000000)
import "io/ioutil" data, err := ioutil.ReadFile(filename) sv := string(data)
Ensure the translated C code behaves exactly like the original J snippet.
require 'files' var=: fread 'foo.txt'
#include <stdio.h> #include <stdlib.h> int main() { char *buffer; FILE *fh = fopen("readentirefile.c", "rb"); if ( fh != NULL ) { fseek(fh, 0L, SEEK_END); long s = ftell(fh); rewind(fh); buffer = malloc(s); if ( buffer != NULL ) { fread(buffer, s, 1, fh); fclose(fh); fh = NULL; fwrite(buffer, s, 1, stdout); free(buffer); } if (fh != NULL) fclose(fh); } return EXIT_SUCCESS; }
Generate a C# translation of this J snippet without changing its computational steps.
require 'files' var=: fread 'foo.txt'
using System.IO; class Program { static void Main(string[] args) { var fileContents = File.ReadAllText("c:\\autoexec.bat"); } }
Change the programming language of this snippet from J to C++ without modifying what it does.
require 'files' var=: fread 'foo.txt'
#include <iostream> #include <fstream> #include <string> #include <iterator> int main( ) { if (std::ifstream infile("sample.txt")) { std::string fileData(std::istreambuf_iterator<char>(infile), std::istreambuf_iterator<char>()); cout << "File has " << fileData.size() << "chars\n"; return 0; } else { std::cout << "file not found!\n"; return 1; } }
Translate this program into Java but keep the logic exactly as in J.
require 'files' var=: fread 'foo.txt'
static Byte[] contentsOf(File file) { return file.contents; }
Port the provided J code into VB while preserving the original functionality.
require 'files' var=: fread 'foo.txt'
dim s s = createobject("scripting.filesystemobject").opentextfile("slurp.vbs",1).readall wscript.echo s
Write a version of this J function in Go with identical behavior.
require 'files' var=: fread 'foo.txt'
import "io/ioutil" data, err := ioutil.ReadFile(filename) sv := string(data)
Ensure the translated C code behaves exactly like the original Julia snippet.
read("/devel/myfile.txt", String)
#include <stdio.h> #include <stdlib.h> int main() { char *buffer; FILE *fh = fopen("readentirefile.c", "rb"); if ( fh != NULL ) { fseek(fh, 0L, SEEK_END); long s = ftell(fh); rewind(fh); buffer = malloc(s); if ( buffer != NULL ) { fread(buffer, s, 1, fh); fclose(fh); fh = NULL; fwrite(buffer, s, 1, stdout); free(buffer); } if (fh != NULL) fclose(fh); } return EXIT_SUCCESS; }
Transform the following Julia implementation into C#, maintaining the same output and logic.
read("/devel/myfile.txt", String)
using System.IO; class Program { static void Main(string[] args) { var fileContents = File.ReadAllText("c:\\autoexec.bat"); } }
Convert the following code from Julia to C++, ensuring the logic remains intact.
read("/devel/myfile.txt", String)
#include <iostream> #include <fstream> #include <string> #include <iterator> int main( ) { if (std::ifstream infile("sample.txt")) { std::string fileData(std::istreambuf_iterator<char>(infile), std::istreambuf_iterator<char>()); cout << "File has " << fileData.size() << "chars\n"; return 0; } else { std::cout << "file not found!\n"; return 1; } }
Generate a VB translation of this Julia snippet without changing its computational steps.
read("/devel/myfile.txt", String)
dim s s = createobject("scripting.filesystemobject").opentextfile("slurp.vbs",1).readall wscript.echo s
Write a version of this Julia function in Go with identical behavior.
read("/devel/myfile.txt", String)
import "io/ioutil" data, err := ioutil.ReadFile(filename) sv := string(data)
Convert the following code from Lua to C, ensuring the logic remains intact.
local file = assert(io.open(filename)) local contents = file:read'*a' file:close()
#include <stdio.h> #include <stdlib.h> int main() { char *buffer; FILE *fh = fopen("readentirefile.c", "rb"); if ( fh != NULL ) { fseek(fh, 0L, SEEK_END); long s = ftell(fh); rewind(fh); buffer = malloc(s); if ( buffer != NULL ) { fread(buffer, s, 1, fh); fclose(fh); fh = NULL; fwrite(buffer, s, 1, stdout); free(buffer); } if (fh != NULL) fclose(fh); } return EXIT_SUCCESS; }
Convert this Lua block to C#, preserving its control flow and logic.
local file = assert(io.open(filename)) local contents = file:read'*a' file:close()
using System.IO; class Program { static void Main(string[] args) { var fileContents = File.ReadAllText("c:\\autoexec.bat"); } }
Transform the following Lua implementation into C++, maintaining the same output and logic.
local file = assert(io.open(filename)) local contents = file:read'*a' file:close()
#include <iostream> #include <fstream> #include <string> #include <iterator> int main( ) { if (std::ifstream infile("sample.txt")) { std::string fileData(std::istreambuf_iterator<char>(infile), std::istreambuf_iterator<char>()); cout << "File has " << fileData.size() << "chars\n"; return 0; } else { std::cout << "file not found!\n"; return 1; } }
Change the programming language of this snippet from Lua to Java without modifying what it does.
local file = assert(io.open(filename)) local contents = file:read'*a' file:close()
static Byte[] contentsOf(File file) { return file.contents; }
Can you help me rewrite this code in Python instead of Lua, keeping it the same logically?
local file = assert(io.open(filename)) local contents = file:read'*a' file:close()
open(filename).read()
Ensure the translated VB code behaves exactly like the original Lua snippet.
local file = assert(io.open(filename)) local contents = file:read'*a' file:close()
dim s s = createobject("scripting.filesystemobject").opentextfile("slurp.vbs",1).readall wscript.echo s
Translate this program into Go but keep the logic exactly as in Lua.
local file = assert(io.open(filename)) local contents = file:read'*a' file:close()
import "io/ioutil" data, err := ioutil.ReadFile(filename) sv := string(data)
Port the provided Mathematica code into C while preserving the original functionality.
Import["filename","String"]
#include <stdio.h> #include <stdlib.h> int main() { char *buffer; FILE *fh = fopen("readentirefile.c", "rb"); if ( fh != NULL ) { fseek(fh, 0L, SEEK_END); long s = ftell(fh); rewind(fh); buffer = malloc(s); if ( buffer != NULL ) { fread(buffer, s, 1, fh); fclose(fh); fh = NULL; fwrite(buffer, s, 1, stdout); free(buffer); } if (fh != NULL) fclose(fh); } return EXIT_SUCCESS; }
Maintain the same structure and functionality when rewriting this code in C#.
Import["filename","String"]
using System.IO; class Program { static void Main(string[] args) { var fileContents = File.ReadAllText("c:\\autoexec.bat"); } }