Instruction
stringlengths
45
106
input_code
stringlengths
1
13.7k
output_code
stringlengths
1
13.7k
Rewrite this program in Python while keeping its functionality equivalent to the F# version.
open NUnit.Framework open FsUnit [<Test>] let ``Validate that the size of the two files is the same`` () = let local = System.IO.FileInfo(__SOURCE_DIRECTORY__ + "\input.txt") let root = System.IO.FileInfo(System.IO.Directory.GetDirectoryRoot(__SOURCE_DIRECTORY__) + "input.txt") local.Length = root.Length |> shou...
import os size = os.path.getsize('input.txt') size = os.path.getsize('/input.txt')
Ensure the translated VB code behaves exactly like the original F# snippet.
open NUnit.Framework open FsUnit [<Test>] let ``Validate that the size of the two files is the same`` () = let local = System.IO.FileInfo(__SOURCE_DIRECTORY__ + "\input.txt") let root = System.IO.FileInfo(System.IO.Directory.GetDirectoryRoot(__SOURCE_DIRECTORY__) + "input.txt") local.Length = root.Length |> shou...
Option Explicit ---- Sub DisplayFileSize(ByVal Path As String, ByVal Filename As String) Dim i As Long If InStr(Len(Path), Path, "\") = 0 Then Path = Path & "\" End If On Error Resume Next i = FileLen(Path & Filename) If Err.Number = 0 Then Debug.Print "file size: " & CStr(i) & " Bytes" Else ...
Preserve the algorithm and functionality while converting the code from F# to Go.
open NUnit.Framework open FsUnit [<Test>] let ``Validate that the size of the two files is the same`` () = let local = System.IO.FileInfo(__SOURCE_DIRECTORY__ + "\input.txt") let root = System.IO.FileInfo(System.IO.Directory.GetDirectoryRoot(__SOURCE_DIRECTORY__) + "input.txt") local.Length = root.Length |> shou...
package main import "fmt" import "os" func printFileSize(f string) { if stat, err := os.Stat(f); err != nil { fmt.Println(err) } else { fmt.Println(stat.Size()) } } func main() { printFileSize("input.txt") printFileSize("/input.txt") }
Write a version of this Factor function in C with identical behavior.
"input.txt" file-info size>> . 1321 "file-does-not-exist.txt" file-info size>> "Unix system call ``stat'' failed:"...
#include <stdlib.h> #include <stdio.h> long getFileSize(const char *filename) { long result; FILE *fh = fopen(filename, "rb"); fseek(fh, 0, SEEK_END); result = ftell(fh); fclose(fh); return result; } int main(void) { printf("%ld\n", getFileSize("input.txt")); printf("%ld\n", getFileSize("/input.txt"))...
Rewrite this program in C# while keeping its functionality equivalent to the Factor version.
"input.txt" file-info size>> . 1321 "file-does-not-exist.txt" file-info size>> "Unix system call ``stat'' failed:"...
using System; using System.IO; class Program { static void Main(string[] args) { Console.WriteLine(new FileInfo("/input.txt").Length); Console.WriteLine(new FileInfo("input.txt").Length); } }
Can you help me rewrite this code in C++ instead of Factor, keeping it the same logically?
"input.txt" file-info size>> . 1321 "file-does-not-exist.txt" file-info size>> "Unix system call ``stat'' failed:"...
#include <iostream> #include <fstream> std::ios::off_type getFileSize(const char *filename) { std::ifstream f(filename); std::ios::pos_type begin = f.tellg(); f.seekg(0, std::ios::end); std::ios::pos_type end = f.tellg(); return end - begin; } int main() { std::cout << getFileSize("input.txt") << std::end...
Transform the following Factor implementation into Java, maintaining the same output and logic.
"input.txt" file-info size>> . 1321 "file-does-not-exist.txt" file-info size>> "Unix system call ``stat'' failed:"...
import java.io.File; public class FileSize { public static void main ( String[] args ) { System.out.println("input.txt  : " + new File("input.txt").length() + " bytes"); System.out.println("/input.txt : " + new File("/input.txt").length() + " bytes"); } }
Ensure the translated Python code behaves exactly like the original Factor snippet.
"input.txt" file-info size>> . 1321 "file-does-not-exist.txt" file-info size>> "Unix system call ``stat'' failed:"...
import os size = os.path.getsize('input.txt') size = os.path.getsize('/input.txt')
Generate a VB translation of this Factor snippet without changing its computational steps.
"input.txt" file-info size>> . 1321 "file-does-not-exist.txt" file-info size>> "Unix system call ``stat'' failed:"...
Option Explicit ---- Sub DisplayFileSize(ByVal Path As String, ByVal Filename As String) Dim i As Long If InStr(Len(Path), Path, "\") = 0 Then Path = Path & "\" End If On Error Resume Next i = FileLen(Path & Filename) If Err.Number = 0 Then Debug.Print "file size: " & CStr(i) & " Bytes" Else ...
Change the programming language of this snippet from Factor to Go without modifying what it does.
"input.txt" file-info size>> . 1321 "file-does-not-exist.txt" file-info size>> "Unix system call ``stat'' failed:"...
package main import "fmt" import "os" func printFileSize(f string) { if stat, err := os.Stat(f); err != nil { fmt.Println(err) } else { fmt.Println(stat.Size()) } } func main() { printFileSize("input.txt") printFileSize("/input.txt") }
Produce a language-to-language conversion: from Forth to C, same semantics.
: .filesize 2dup type ." is " r/o open-file throw dup file-size throw <# #s #> type ." bytes long." cr close-file throw ; s" input.txt" .filesize s" /input.txt" .filesize
#include <stdlib.h> #include <stdio.h> long getFileSize(const char *filename) { long result; FILE *fh = fopen(filename, "rb"); fseek(fh, 0, SEEK_END); result = ftell(fh); fclose(fh); return result; } int main(void) { printf("%ld\n", getFileSize("input.txt")); printf("%ld\n", getFileSize("/input.txt"))...
Rewrite this program in C# while keeping its functionality equivalent to the Forth version.
: .filesize 2dup type ." is " r/o open-file throw dup file-size throw <# #s #> type ." bytes long." cr close-file throw ; s" input.txt" .filesize s" /input.txt" .filesize
using System; using System.IO; class Program { static void Main(string[] args) { Console.WriteLine(new FileInfo("/input.txt").Length); Console.WriteLine(new FileInfo("input.txt").Length); } }
Write a version of this Forth function in C++ with identical behavior.
: .filesize 2dup type ." is " r/o open-file throw dup file-size throw <# #s #> type ." bytes long." cr close-file throw ; s" input.txt" .filesize s" /input.txt" .filesize
#include <iostream> #include <fstream> std::ios::off_type getFileSize(const char *filename) { std::ifstream f(filename); std::ios::pos_type begin = f.tellg(); f.seekg(0, std::ios::end); std::ios::pos_type end = f.tellg(); return end - begin; } int main() { std::cout << getFileSize("input.txt") << std::end...
Produce a functionally identical Java code for the snippet given in Forth.
: .filesize 2dup type ." is " r/o open-file throw dup file-size throw <# #s #> type ." bytes long." cr close-file throw ; s" input.txt" .filesize s" /input.txt" .filesize
import java.io.File; public class FileSize { public static void main ( String[] args ) { System.out.println("input.txt  : " + new File("input.txt").length() + " bytes"); System.out.println("/input.txt : " + new File("/input.txt").length() + " bytes"); } }
Produce a functionally identical Python code for the snippet given in Forth.
: .filesize 2dup type ." is " r/o open-file throw dup file-size throw <# #s #> type ." bytes long." cr close-file throw ; s" input.txt" .filesize s" /input.txt" .filesize
import os size = os.path.getsize('input.txt') size = os.path.getsize('/input.txt')
Can you help me rewrite this code in VB instead of Forth, keeping it the same logically?
: .filesize 2dup type ." is " r/o open-file throw dup file-size throw <# #s #> type ." bytes long." cr close-file throw ; s" input.txt" .filesize s" /input.txt" .filesize
Option Explicit ---- Sub DisplayFileSize(ByVal Path As String, ByVal Filename As String) Dim i As Long If InStr(Len(Path), Path, "\") = 0 Then Path = Path & "\" End If On Error Resume Next i = FileLen(Path & Filename) If Err.Number = 0 Then Debug.Print "file size: " & CStr(i) & " Bytes" Else ...
Write the same code in Go as shown below in Forth.
: .filesize 2dup type ." is " r/o open-file throw dup file-size throw <# #s #> type ." bytes long." cr close-file throw ; s" input.txt" .filesize s" /input.txt" .filesize
package main import "fmt" import "os" func printFileSize(f string) { if stat, err := os.Stat(f); err != nil { fmt.Println(err) } else { fmt.Println(stat.Size()) } } func main() { printFileSize("input.txt") printFileSize("/input.txt") }
Ensure the translated C# code behaves exactly like the original Fortran snippet.
use :: iso_fortran_env, only : FILE_STORAGE_SIZE implicit none character(len=*),parameter :: filename(*)=[character(len=256) :: 'input.txt', '/input.txt'] integer :: file_size, i do i=1,size(filename) INQUIRE(FILE=filename(i), SIZE=file_size) write(*,*)'size of fil...
using System; using System.IO; class Program { static void Main(string[] args) { Console.WriteLine(new FileInfo("/input.txt").Length); Console.WriteLine(new FileInfo("input.txt").Length); } }
Generate a C++ translation of this Fortran snippet without changing its computational steps.
use :: iso_fortran_env, only : FILE_STORAGE_SIZE implicit none character(len=*),parameter :: filename(*)=[character(len=256) :: 'input.txt', '/input.txt'] integer :: file_size, i do i=1,size(filename) INQUIRE(FILE=filename(i), SIZE=file_size) write(*,*)'size of fil...
#include <iostream> #include <fstream> std::ios::off_type getFileSize(const char *filename) { std::ifstream f(filename); std::ios::pos_type begin = f.tellg(); f.seekg(0, std::ios::end); std::ios::pos_type end = f.tellg(); return end - begin; } int main() { std::cout << getFileSize("input.txt") << std::end...
Port the provided Fortran code into C while preserving the original functionality.
use :: iso_fortran_env, only : FILE_STORAGE_SIZE implicit none character(len=*),parameter :: filename(*)=[character(len=256) :: 'input.txt', '/input.txt'] integer :: file_size, i do i=1,size(filename) INQUIRE(FILE=filename(i), SIZE=file_size) write(*,*)'size of fil...
#include <stdlib.h> #include <stdio.h> long getFileSize(const char *filename) { long result; FILE *fh = fopen(filename, "rb"); fseek(fh, 0, SEEK_END); result = ftell(fh); fclose(fh); return result; } int main(void) { printf("%ld\n", getFileSize("input.txt")); printf("%ld\n", getFileSize("/input.txt"))...
Translate the given Fortran code snippet into Go without altering its behavior.
use :: iso_fortran_env, only : FILE_STORAGE_SIZE implicit none character(len=*),parameter :: filename(*)=[character(len=256) :: 'input.txt', '/input.txt'] integer :: file_size, i do i=1,size(filename) INQUIRE(FILE=filename(i), SIZE=file_size) write(*,*)'size of fil...
package main import "fmt" import "os" func printFileSize(f string) { if stat, err := os.Stat(f); err != nil { fmt.Println(err) } else { fmt.Println(stat.Size()) } } func main() { printFileSize("input.txt") printFileSize("/input.txt") }
Maintain the same structure and functionality when rewriting this code in Java.
use :: iso_fortran_env, only : FILE_STORAGE_SIZE implicit none character(len=*),parameter :: filename(*)=[character(len=256) :: 'input.txt', '/input.txt'] integer :: file_size, i do i=1,size(filename) INQUIRE(FILE=filename(i), SIZE=file_size) write(*,*)'size of fil...
import java.io.File; public class FileSize { public static void main ( String[] args ) { System.out.println("input.txt  : " + new File("input.txt").length() + " bytes"); System.out.println("/input.txt : " + new File("/input.txt").length() + " bytes"); } }
Generate a Python translation of this Fortran snippet without changing its computational steps.
use :: iso_fortran_env, only : FILE_STORAGE_SIZE implicit none character(len=*),parameter :: filename(*)=[character(len=256) :: 'input.txt', '/input.txt'] integer :: file_size, i do i=1,size(filename) INQUIRE(FILE=filename(i), SIZE=file_size) write(*,*)'size of fil...
import os size = os.path.getsize('input.txt') size = os.path.getsize('/input.txt')
Translate this program into VB but keep the logic exactly as in Fortran.
use :: iso_fortran_env, only : FILE_STORAGE_SIZE implicit none character(len=*),parameter :: filename(*)=[character(len=256) :: 'input.txt', '/input.txt'] integer :: file_size, i do i=1,size(filename) INQUIRE(FILE=filename(i), SIZE=file_size) write(*,*)'size of fil...
Option Explicit ---- Sub DisplayFileSize(ByVal Path As String, ByVal Filename As String) Dim i As Long If InStr(Len(Path), Path, "\") = 0 Then Path = Path & "\" End If On Error Resume Next i = FileLen(Path & Filename) If Err.Number = 0 Then Debug.Print "file size: " & CStr(i) & " Bytes" Else ...
Write the same algorithm in PHP as shown in this Fortran implementation.
use :: iso_fortran_env, only : FILE_STORAGE_SIZE implicit none character(len=*),parameter :: filename(*)=[character(len=256) :: 'input.txt', '/input.txt'] integer :: file_size, i do i=1,size(filename) INQUIRE(FILE=filename(i), SIZE=file_size) write(*,*)'size of fil...
<?php echo filesize('input.txt'), "\n"; echo filesize('/input.txt'), "\n"; ?>
Transform the following Groovy implementation into C, maintaining the same output and logic.
println new File('index.txt').length(); println new File('/index.txt').length();
#include <stdlib.h> #include <stdio.h> long getFileSize(const char *filename) { long result; FILE *fh = fopen(filename, "rb"); fseek(fh, 0, SEEK_END); result = ftell(fh); fclose(fh); return result; } int main(void) { printf("%ld\n", getFileSize("input.txt")); printf("%ld\n", getFileSize("/input.txt"))...
Translate this program into C# but keep the logic exactly as in Groovy.
println new File('index.txt').length(); println new File('/index.txt').length();
using System; using System.IO; class Program { static void Main(string[] args) { Console.WriteLine(new FileInfo("/input.txt").Length); Console.WriteLine(new FileInfo("input.txt").Length); } }
Produce a language-to-language conversion: from Groovy to C++, same semantics.
println new File('index.txt').length(); println new File('/index.txt').length();
#include <iostream> #include <fstream> std::ios::off_type getFileSize(const char *filename) { std::ifstream f(filename); std::ios::pos_type begin = f.tellg(); f.seekg(0, std::ios::end); std::ios::pos_type end = f.tellg(); return end - begin; } int main() { std::cout << getFileSize("input.txt") << std::end...
Ensure the translated Java code behaves exactly like the original Groovy snippet.
println new File('index.txt').length(); println new File('/index.txt').length();
import java.io.File; public class FileSize { public static void main ( String[] args ) { System.out.println("input.txt  : " + new File("input.txt").length() + " bytes"); System.out.println("/input.txt : " + new File("/input.txt").length() + " bytes"); } }
Translate the given Groovy code snippet into Python without altering its behavior.
println new File('index.txt').length(); println new File('/index.txt').length();
import os size = os.path.getsize('input.txt') size = os.path.getsize('/input.txt')
Translate the given Groovy code snippet into VB without altering its behavior.
println new File('index.txt').length(); println new File('/index.txt').length();
Option Explicit ---- Sub DisplayFileSize(ByVal Path As String, ByVal Filename As String) Dim i As Long If InStr(Len(Path), Path, "\") = 0 Then Path = Path & "\" End If On Error Resume Next i = FileLen(Path & Filename) If Err.Number = 0 Then Debug.Print "file size: " & CStr(i) & " Bytes" Else ...
Rewrite this program in Go while keeping its functionality equivalent to the Groovy version.
println new File('index.txt').length(); println new File('/index.txt').length();
package main import "fmt" import "os" func printFileSize(f string) { if stat, err := os.Stat(f); err != nil { fmt.Println(err) } else { fmt.Println(stat.Size()) } } func main() { printFileSize("input.txt") printFileSize("/input.txt") }
Change the following Haskell code into C without altering its purpose.
import System.IO printFileSize filename = withFile filename ReadMode hFileSize >>= print main = mapM_ printFileSize ["input.txt", "/input.txt"]
#include <stdlib.h> #include <stdio.h> long getFileSize(const char *filename) { long result; FILE *fh = fopen(filename, "rb"); fseek(fh, 0, SEEK_END); result = ftell(fh); fclose(fh); return result; } int main(void) { printf("%ld\n", getFileSize("input.txt")); printf("%ld\n", getFileSize("/input.txt"))...
Transform the following Haskell implementation into C++, maintaining the same output and logic.
import System.IO printFileSize filename = withFile filename ReadMode hFileSize >>= print main = mapM_ printFileSize ["input.txt", "/input.txt"]
#include <iostream> #include <fstream> std::ios::off_type getFileSize(const char *filename) { std::ifstream f(filename); std::ios::pos_type begin = f.tellg(); f.seekg(0, std::ios::end); std::ios::pos_type end = f.tellg(); return end - begin; } int main() { std::cout << getFileSize("input.txt") << std::end...
Keep all operations the same but rewrite the snippet in Java.
import System.IO printFileSize filename = withFile filename ReadMode hFileSize >>= print main = mapM_ printFileSize ["input.txt", "/input.txt"]
import java.io.File; public class FileSize { public static void main ( String[] args ) { System.out.println("input.txt  : " + new File("input.txt").length() + " bytes"); System.out.println("/input.txt : " + new File("/input.txt").length() + " bytes"); } }
Generate a Python translation of this Haskell snippet without changing its computational steps.
import System.IO printFileSize filename = withFile filename ReadMode hFileSize >>= print main = mapM_ printFileSize ["input.txt", "/input.txt"]
import os size = os.path.getsize('input.txt') size = os.path.getsize('/input.txt')
Please provide an equivalent version of this Haskell code in VB.
import System.IO printFileSize filename = withFile filename ReadMode hFileSize >>= print main = mapM_ printFileSize ["input.txt", "/input.txt"]
Option Explicit ---- Sub DisplayFileSize(ByVal Path As String, ByVal Filename As String) Dim i As Long If InStr(Len(Path), Path, "\") = 0 Then Path = Path & "\" End If On Error Resume Next i = FileLen(Path & Filename) If Err.Number = 0 Then Debug.Print "file size: " & CStr(i) & " Bytes" Else ...
Convert this Haskell snippet to Go and keep its semantics consistent.
import System.IO printFileSize filename = withFile filename ReadMode hFileSize >>= print main = mapM_ printFileSize ["input.txt", "/input.txt"]
package main import "fmt" import "os" func printFileSize(f string) { if stat, err := os.Stat(f); err != nil { fmt.Println(err) } else { fmt.Println(stat.Size()) } } func main() { printFileSize("input.txt") printFileSize("/input.txt") }
Translate this program into C but keep the logic exactly as in J.
require 'files' fsize 'input.txt';'/input.txt'
#include <stdlib.h> #include <stdio.h> long getFileSize(const char *filename) { long result; FILE *fh = fopen(filename, "rb"); fseek(fh, 0, SEEK_END); result = ftell(fh); fclose(fh); return result; } int main(void) { printf("%ld\n", getFileSize("input.txt")); printf("%ld\n", getFileSize("/input.txt"))...
Generate an equivalent C# version of this J code.
require 'files' fsize 'input.txt';'/input.txt'
using System; using System.IO; class Program { static void Main(string[] args) { Console.WriteLine(new FileInfo("/input.txt").Length); Console.WriteLine(new FileInfo("input.txt").Length); } }
Port the following code from J to C++ with equivalent syntax and logic.
require 'files' fsize 'input.txt';'/input.txt'
#include <iostream> #include <fstream> std::ios::off_type getFileSize(const char *filename) { std::ifstream f(filename); std::ios::pos_type begin = f.tellg(); f.seekg(0, std::ios::end); std::ios::pos_type end = f.tellg(); return end - begin; } int main() { std::cout << getFileSize("input.txt") << std::end...
Port the provided J code into Java while preserving the original functionality.
require 'files' fsize 'input.txt';'/input.txt'
import java.io.File; public class FileSize { public static void main ( String[] args ) { System.out.println("input.txt  : " + new File("input.txt").length() + " bytes"); System.out.println("/input.txt : " + new File("/input.txt").length() + " bytes"); } }
Convert this J block to Python, preserving its control flow and logic.
require 'files' fsize 'input.txt';'/input.txt'
import os size = os.path.getsize('input.txt') size = os.path.getsize('/input.txt')
Produce a language-to-language conversion: from J to VB, same semantics.
require 'files' fsize 'input.txt';'/input.txt'
Option Explicit ---- Sub DisplayFileSize(ByVal Path As String, ByVal Filename As String) Dim i As Long If InStr(Len(Path), Path, "\") = 0 Then Path = Path & "\" End If On Error Resume Next i = FileLen(Path & Filename) If Err.Number = 0 Then Debug.Print "file size: " & CStr(i) & " Bytes" Else ...
Produce a language-to-language conversion: from J to Go, same semantics.
require 'files' fsize 'input.txt';'/input.txt'
package main import "fmt" import "os" func printFileSize(f string) { if stat, err := os.Stat(f); err != nil { fmt.Println(err) } else { fmt.Println(stat.Size()) } } func main() { printFileSize("input.txt") printFileSize("/input.txt") }
Change the following Julia code into C without altering its purpose.
println(filesize("input.txt")) println(filesize("/input.txt"))
#include <stdlib.h> #include <stdio.h> long getFileSize(const char *filename) { long result; FILE *fh = fopen(filename, "rb"); fseek(fh, 0, SEEK_END); result = ftell(fh); fclose(fh); return result; } int main(void) { printf("%ld\n", getFileSize("input.txt")); printf("%ld\n", getFileSize("/input.txt"))...
Write a version of this Julia function in C# with identical behavior.
println(filesize("input.txt")) println(filesize("/input.txt"))
using System; using System.IO; class Program { static void Main(string[] args) { Console.WriteLine(new FileInfo("/input.txt").Length); Console.WriteLine(new FileInfo("input.txt").Length); } }
Rewrite this program in C++ while keeping its functionality equivalent to the Julia version.
println(filesize("input.txt")) println(filesize("/input.txt"))
#include <iostream> #include <fstream> std::ios::off_type getFileSize(const char *filename) { std::ifstream f(filename); std::ios::pos_type begin = f.tellg(); f.seekg(0, std::ios::end); std::ios::pos_type end = f.tellg(); return end - begin; } int main() { std::cout << getFileSize("input.txt") << std::end...
Write the same algorithm in Java as shown in this Julia implementation.
println(filesize("input.txt")) println(filesize("/input.txt"))
import java.io.File; public class FileSize { public static void main ( String[] args ) { System.out.println("input.txt  : " + new File("input.txt").length() + " bytes"); System.out.println("/input.txt : " + new File("/input.txt").length() + " bytes"); } }
Keep all operations the same but rewrite the snippet in Python.
println(filesize("input.txt")) println(filesize("/input.txt"))
import os size = os.path.getsize('input.txt') size = os.path.getsize('/input.txt')
Translate this program into VB but keep the logic exactly as in Julia.
println(filesize("input.txt")) println(filesize("/input.txt"))
Option Explicit ---- Sub DisplayFileSize(ByVal Path As String, ByVal Filename As String) Dim i As Long If InStr(Len(Path), Path, "\") = 0 Then Path = Path & "\" End If On Error Resume Next i = FileLen(Path & Filename) If Err.Number = 0 Then Debug.Print "file size: " & CStr(i) & " Bytes" Else ...
Ensure the translated Go code behaves exactly like the original Julia snippet.
println(filesize("input.txt")) println(filesize("/input.txt"))
package main import "fmt" import "os" func printFileSize(f string) { if stat, err := os.Stat(f); err != nil { fmt.Println(err) } else { fmt.Println(stat.Size()) } } func main() { printFileSize("input.txt") printFileSize("/input.txt") }
Can you help me rewrite this code in C instead of Lua, keeping it the same logically?
function GetFileSize( filename ) local fp = io.open( filename ) if fp == nil then return nil end local filesize = fp:seek( "end" ) fp:close() return filesize end
#include <stdlib.h> #include <stdio.h> long getFileSize(const char *filename) { long result; FILE *fh = fopen(filename, "rb"); fseek(fh, 0, SEEK_END); result = ftell(fh); fclose(fh); return result; } int main(void) { printf("%ld\n", getFileSize("input.txt")); printf("%ld\n", getFileSize("/input.txt"))...
Rewrite this program in C# while keeping its functionality equivalent to the Lua version.
function GetFileSize( filename ) local fp = io.open( filename ) if fp == nil then return nil end local filesize = fp:seek( "end" ) fp:close() return filesize end
using System; using System.IO; class Program { static void Main(string[] args) { Console.WriteLine(new FileInfo("/input.txt").Length); Console.WriteLine(new FileInfo("input.txt").Length); } }
Preserve the algorithm and functionality while converting the code from Lua to C++.
function GetFileSize( filename ) local fp = io.open( filename ) if fp == nil then return nil end local filesize = fp:seek( "end" ) fp:close() return filesize end
#include <iostream> #include <fstream> std::ios::off_type getFileSize(const char *filename) { std::ifstream f(filename); std::ios::pos_type begin = f.tellg(); f.seekg(0, std::ios::end); std::ios::pos_type end = f.tellg(); return end - begin; } int main() { std::cout << getFileSize("input.txt") << std::end...
Translate this program into Java but keep the logic exactly as in Lua.
function GetFileSize( filename ) local fp = io.open( filename ) if fp == nil then return nil end local filesize = fp:seek( "end" ) fp:close() return filesize end
import java.io.File; public class FileSize { public static void main ( String[] args ) { System.out.println("input.txt  : " + new File("input.txt").length() + " bytes"); System.out.println("/input.txt : " + new File("/input.txt").length() + " bytes"); } }
Convert this Lua snippet to Python and keep its semantics consistent.
function GetFileSize( filename ) local fp = io.open( filename ) if fp == nil then return nil end local filesize = fp:seek( "end" ) fp:close() return filesize end
import os size = os.path.getsize('input.txt') size = os.path.getsize('/input.txt')
Maintain the same structure and functionality when rewriting this code in VB.
function GetFileSize( filename ) local fp = io.open( filename ) if fp == nil then return nil end local filesize = fp:seek( "end" ) fp:close() return filesize end
Option Explicit ---- Sub DisplayFileSize(ByVal Path As String, ByVal Filename As String) Dim i As Long If InStr(Len(Path), Path, "\") = 0 Then Path = Path & "\" End If On Error Resume Next i = FileLen(Path & Filename) If Err.Number = 0 Then Debug.Print "file size: " & CStr(i) & " Bytes" Else ...
Port the following code from Lua to Go with equivalent syntax and logic.
function GetFileSize( filename ) local fp = io.open( filename ) if fp == nil then return nil end local filesize = fp:seek( "end" ) fp:close() return filesize end
package main import "fmt" import "os" func printFileSize(f string) { if stat, err := os.Stat(f); err != nil { fmt.Println(err) } else { fmt.Println(stat.Size()) } } func main() { printFileSize("input.txt") printFileSize("/input.txt") }
Please provide an equivalent version of this Mathematica code in C.
FileByteCount["input.txt"] FileByteCount[FileNameJoin[{$RootDirectory, "input.txt"}]]
#include <stdlib.h> #include <stdio.h> long getFileSize(const char *filename) { long result; FILE *fh = fopen(filename, "rb"); fseek(fh, 0, SEEK_END); result = ftell(fh); fclose(fh); return result; } int main(void) { printf("%ld\n", getFileSize("input.txt")); printf("%ld\n", getFileSize("/input.txt"))...
Port the following code from Mathematica to C# with equivalent syntax and logic.
FileByteCount["input.txt"] FileByteCount[FileNameJoin[{$RootDirectory, "input.txt"}]]
using System; using System.IO; class Program { static void Main(string[] args) { Console.WriteLine(new FileInfo("/input.txt").Length); Console.WriteLine(new FileInfo("input.txt").Length); } }
Change the following Mathematica code into C++ without altering its purpose.
FileByteCount["input.txt"] FileByteCount[FileNameJoin[{$RootDirectory, "input.txt"}]]
#include <iostream> #include <fstream> std::ios::off_type getFileSize(const char *filename) { std::ifstream f(filename); std::ios::pos_type begin = f.tellg(); f.seekg(0, std::ios::end); std::ios::pos_type end = f.tellg(); return end - begin; } int main() { std::cout << getFileSize("input.txt") << std::end...
Write a version of this Mathematica function in Java with identical behavior.
FileByteCount["input.txt"] FileByteCount[FileNameJoin[{$RootDirectory, "input.txt"}]]
import java.io.File; public class FileSize { public static void main ( String[] args ) { System.out.println("input.txt  : " + new File("input.txt").length() + " bytes"); System.out.println("/input.txt : " + new File("/input.txt").length() + " bytes"); } }
Can you help me rewrite this code in Python instead of Mathematica, keeping it the same logically?
FileByteCount["input.txt"] FileByteCount[FileNameJoin[{$RootDirectory, "input.txt"}]]
import os size = os.path.getsize('input.txt') size = os.path.getsize('/input.txt')
Rewrite the snippet below in VB so it works the same as the original Mathematica code.
FileByteCount["input.txt"] FileByteCount[FileNameJoin[{$RootDirectory, "input.txt"}]]
Option Explicit ---- Sub DisplayFileSize(ByVal Path As String, ByVal Filename As String) Dim i As Long If InStr(Len(Path), Path, "\") = 0 Then Path = Path & "\" End If On Error Resume Next i = FileLen(Path & Filename) If Err.Number = 0 Then Debug.Print "file size: " & CStr(i) & " Bytes" Else ...
Change the following Mathematica code into Go without altering its purpose.
FileByteCount["input.txt"] FileByteCount[FileNameJoin[{$RootDirectory, "input.txt"}]]
package main import "fmt" import "os" func printFileSize(f string) { if stat, err := os.Stat(f); err != nil { fmt.Println(err) } else { fmt.Println(stat.Size()) } } func main() { printFileSize("input.txt") printFileSize("/input.txt") }
Generate an equivalent C version of this MATLAB code.
d1 = dir('input.txt'); d2 = dir('/input.txt'); fprintf('Size of input.txt is fprintf('Size of /input.txt is
#include <stdlib.h> #include <stdio.h> long getFileSize(const char *filename) { long result; FILE *fh = fopen(filename, "rb"); fseek(fh, 0, SEEK_END); result = ftell(fh); fclose(fh); return result; } int main(void) { printf("%ld\n", getFileSize("input.txt")); printf("%ld\n", getFileSize("/input.txt"))...
Convert the following code from MATLAB to C#, ensuring the logic remains intact.
d1 = dir('input.txt'); d2 = dir('/input.txt'); fprintf('Size of input.txt is fprintf('Size of /input.txt is
using System; using System.IO; class Program { static void Main(string[] args) { Console.WriteLine(new FileInfo("/input.txt").Length); Console.WriteLine(new FileInfo("input.txt").Length); } }
Produce a functionally identical C++ code for the snippet given in MATLAB.
d1 = dir('input.txt'); d2 = dir('/input.txt'); fprintf('Size of input.txt is fprintf('Size of /input.txt is
#include <iostream> #include <fstream> std::ios::off_type getFileSize(const char *filename) { std::ifstream f(filename); std::ios::pos_type begin = f.tellg(); f.seekg(0, std::ios::end); std::ios::pos_type end = f.tellg(); return end - begin; } int main() { std::cout << getFileSize("input.txt") << std::end...
Please provide an equivalent version of this MATLAB code in Java.
d1 = dir('input.txt'); d2 = dir('/input.txt'); fprintf('Size of input.txt is fprintf('Size of /input.txt is
import java.io.File; public class FileSize { public static void main ( String[] args ) { System.out.println("input.txt  : " + new File("input.txt").length() + " bytes"); System.out.println("/input.txt : " + new File("/input.txt").length() + " bytes"); } }
Keep all operations the same but rewrite the snippet in Python.
d1 = dir('input.txt'); d2 = dir('/input.txt'); fprintf('Size of input.txt is fprintf('Size of /input.txt is
import os size = os.path.getsize('input.txt') size = os.path.getsize('/input.txt')
Preserve the algorithm and functionality while converting the code from MATLAB to VB.
d1 = dir('input.txt'); d2 = dir('/input.txt'); fprintf('Size of input.txt is fprintf('Size of /input.txt is
Option Explicit ---- Sub DisplayFileSize(ByVal Path As String, ByVal Filename As String) Dim i As Long If InStr(Len(Path), Path, "\") = 0 Then Path = Path & "\" End If On Error Resume Next i = FileLen(Path & Filename) If Err.Number = 0 Then Debug.Print "file size: " & CStr(i) & " Bytes" Else ...
Can you help me rewrite this code in Go instead of MATLAB, keeping it the same logically?
d1 = dir('input.txt'); d2 = dir('/input.txt'); fprintf('Size of input.txt is fprintf('Size of /input.txt is
package main import "fmt" import "os" func printFileSize(f string) { if stat, err := os.Stat(f); err != nil { fmt.Println(err) } else { fmt.Println(stat.Size()) } } func main() { printFileSize("input.txt") printFileSize("/input.txt") }
Write a version of this Nim function in C with identical behavior.
import os echo getFileSize "input.txt" echo getFileSize "/input.txt"
#include <stdlib.h> #include <stdio.h> long getFileSize(const char *filename) { long result; FILE *fh = fopen(filename, "rb"); fseek(fh, 0, SEEK_END); result = ftell(fh); fclose(fh); return result; } int main(void) { printf("%ld\n", getFileSize("input.txt")); printf("%ld\n", getFileSize("/input.txt"))...
Keep all operations the same but rewrite the snippet in C#.
import os echo getFileSize "input.txt" echo getFileSize "/input.txt"
using System; using System.IO; class Program { static void Main(string[] args) { Console.WriteLine(new FileInfo("/input.txt").Length); Console.WriteLine(new FileInfo("input.txt").Length); } }
Generate an equivalent C++ version of this Nim code.
import os echo getFileSize "input.txt" echo getFileSize "/input.txt"
#include <iostream> #include <fstream> std::ios::off_type getFileSize(const char *filename) { std::ifstream f(filename); std::ios::pos_type begin = f.tellg(); f.seekg(0, std::ios::end); std::ios::pos_type end = f.tellg(); return end - begin; } int main() { std::cout << getFileSize("input.txt") << std::end...
Translate this program into Java but keep the logic exactly as in Nim.
import os echo getFileSize "input.txt" echo getFileSize "/input.txt"
import java.io.File; public class FileSize { public static void main ( String[] args ) { System.out.println("input.txt  : " + new File("input.txt").length() + " bytes"); System.out.println("/input.txt : " + new File("/input.txt").length() + " bytes"); } }
Change the following Nim code into Python without altering its purpose.
import os echo getFileSize "input.txt" echo getFileSize "/input.txt"
import os size = os.path.getsize('input.txt') size = os.path.getsize('/input.txt')
Generate an equivalent VB version of this Nim code.
import os echo getFileSize "input.txt" echo getFileSize "/input.txt"
Option Explicit ---- Sub DisplayFileSize(ByVal Path As String, ByVal Filename As String) Dim i As Long If InStr(Len(Path), Path, "\") = 0 Then Path = Path & "\" End If On Error Resume Next i = FileLen(Path & Filename) If Err.Number = 0 Then Debug.Print "file size: " & CStr(i) & " Bytes" Else ...
Change the following Nim code into Go without altering its purpose.
import os echo getFileSize "input.txt" echo getFileSize "/input.txt"
package main import "fmt" import "os" func printFileSize(f string) { if stat, err := os.Stat(f); err != nil { fmt.Println(err) } else { fmt.Println(stat.Size()) } } func main() { printFileSize("input.txt") printFileSize("/input.txt") }
Change the following OCaml code into C without altering its purpose.
let printFileSize filename = let ic = open_in filename in Printf.printf "%d\n" (in_channel_length ic); close_in ic ;; printFileSize "input.txt" ;; printFileSize "/input.txt" ;;
#include <stdlib.h> #include <stdio.h> long getFileSize(const char *filename) { long result; FILE *fh = fopen(filename, "rb"); fseek(fh, 0, SEEK_END); result = ftell(fh); fclose(fh); return result; } int main(void) { printf("%ld\n", getFileSize("input.txt")); printf("%ld\n", getFileSize("/input.txt"))...
Maintain the same structure and functionality when rewriting this code in C#.
let printFileSize filename = let ic = open_in filename in Printf.printf "%d\n" (in_channel_length ic); close_in ic ;; printFileSize "input.txt" ;; printFileSize "/input.txt" ;;
using System; using System.IO; class Program { static void Main(string[] args) { Console.WriteLine(new FileInfo("/input.txt").Length); Console.WriteLine(new FileInfo("input.txt").Length); } }
Port the following code from OCaml to C++ with equivalent syntax and logic.
let printFileSize filename = let ic = open_in filename in Printf.printf "%d\n" (in_channel_length ic); close_in ic ;; printFileSize "input.txt" ;; printFileSize "/input.txt" ;;
#include <iostream> #include <fstream> std::ios::off_type getFileSize(const char *filename) { std::ifstream f(filename); std::ios::pos_type begin = f.tellg(); f.seekg(0, std::ios::end); std::ios::pos_type end = f.tellg(); return end - begin; } int main() { std::cout << getFileSize("input.txt") << std::end...
Please provide an equivalent version of this OCaml code in Java.
let printFileSize filename = let ic = open_in filename in Printf.printf "%d\n" (in_channel_length ic); close_in ic ;; printFileSize "input.txt" ;; printFileSize "/input.txt" ;;
import java.io.File; public class FileSize { public static void main ( String[] args ) { System.out.println("input.txt  : " + new File("input.txt").length() + " bytes"); System.out.println("/input.txt : " + new File("/input.txt").length() + " bytes"); } }
Change the programming language of this snippet from OCaml to Python without modifying what it does.
let printFileSize filename = let ic = open_in filename in Printf.printf "%d\n" (in_channel_length ic); close_in ic ;; printFileSize "input.txt" ;; printFileSize "/input.txt" ;;
import os size = os.path.getsize('input.txt') size = os.path.getsize('/input.txt')
Preserve the algorithm and functionality while converting the code from OCaml to VB.
let printFileSize filename = let ic = open_in filename in Printf.printf "%d\n" (in_channel_length ic); close_in ic ;; printFileSize "input.txt" ;; printFileSize "/input.txt" ;;
Option Explicit ---- Sub DisplayFileSize(ByVal Path As String, ByVal Filename As String) Dim i As Long If InStr(Len(Path), Path, "\") = 0 Then Path = Path & "\" End If On Error Resume Next i = FileLen(Path & Filename) If Err.Number = 0 Then Debug.Print "file size: " & CStr(i) & " Bytes" Else ...
Translate this program into Go but keep the logic exactly as in OCaml.
let printFileSize filename = let ic = open_in filename in Printf.printf "%d\n" (in_channel_length ic); close_in ic ;; printFileSize "input.txt" ;; printFileSize "/input.txt" ;;
package main import "fmt" import "os" func printFileSize(f string) { if stat, err := os.Stat(f); err != nil { fmt.Println(err) } else { fmt.Println(stat.Size()) } } func main() { printFileSize("input.txt") printFileSize("/input.txt") }
Rewrite this program in C while keeping its functionality equivalent to the Perl version.
my $size1 = -s 'input.txt'; my $size2 = -s '/input.txt';
#include <stdlib.h> #include <stdio.h> long getFileSize(const char *filename) { long result; FILE *fh = fopen(filename, "rb"); fseek(fh, 0, SEEK_END); result = ftell(fh); fclose(fh); return result; } int main(void) { printf("%ld\n", getFileSize("input.txt")); printf("%ld\n", getFileSize("/input.txt"))...
Preserve the algorithm and functionality while converting the code from Perl to C#.
my $size1 = -s 'input.txt'; my $size2 = -s '/input.txt';
using System; using System.IO; class Program { static void Main(string[] args) { Console.WriteLine(new FileInfo("/input.txt").Length); Console.WriteLine(new FileInfo("input.txt").Length); } }
Write the same code in C++ as shown below in Perl.
my $size1 = -s 'input.txt'; my $size2 = -s '/input.txt';
#include <iostream> #include <fstream> std::ios::off_type getFileSize(const char *filename) { std::ifstream f(filename); std::ios::pos_type begin = f.tellg(); f.seekg(0, std::ios::end); std::ios::pos_type end = f.tellg(); return end - begin; } int main() { std::cout << getFileSize("input.txt") << std::end...
Convert this Perl snippet to Java and keep its semantics consistent.
my $size1 = -s 'input.txt'; my $size2 = -s '/input.txt';
import java.io.File; public class FileSize { public static void main ( String[] args ) { System.out.println("input.txt  : " + new File("input.txt").length() + " bytes"); System.out.println("/input.txt : " + new File("/input.txt").length() + " bytes"); } }
Preserve the algorithm and functionality while converting the code from Perl to Python.
my $size1 = -s 'input.txt'; my $size2 = -s '/input.txt';
import os size = os.path.getsize('input.txt') size = os.path.getsize('/input.txt')
Generate an equivalent VB version of this Perl code.
my $size1 = -s 'input.txt'; my $size2 = -s '/input.txt';
Option Explicit ---- Sub DisplayFileSize(ByVal Path As String, ByVal Filename As String) Dim i As Long If InStr(Len(Path), Path, "\") = 0 Then Path = Path & "\" End If On Error Resume Next i = FileLen(Path & Filename) If Err.Number = 0 Then Debug.Print "file size: " & CStr(i) & " Bytes" Else ...
Port the following code from Perl to Go with equivalent syntax and logic.
my $size1 = -s 'input.txt'; my $size2 = -s '/input.txt';
package main import "fmt" import "os" func printFileSize(f string) { if stat, err := os.Stat(f); err != nil { fmt.Println(err) } else { fmt.Println(stat.Size()) } } func main() { printFileSize("input.txt") printFileSize("/input.txt") }
Change the programming language of this snippet from PowerShell to C without modifying what it does.
Get-ChildItem input.txt | Select-Object Name,Length Get-ChildItem \input.txt | Select-Object Name,Length
#include <stdlib.h> #include <stdio.h> long getFileSize(const char *filename) { long result; FILE *fh = fopen(filename, "rb"); fseek(fh, 0, SEEK_END); result = ftell(fh); fclose(fh); return result; } int main(void) { printf("%ld\n", getFileSize("input.txt")); printf("%ld\n", getFileSize("/input.txt"))...
Write the same code in C# as shown below in PowerShell.
Get-ChildItem input.txt | Select-Object Name,Length Get-ChildItem \input.txt | Select-Object Name,Length
using System; using System.IO; class Program { static void Main(string[] args) { Console.WriteLine(new FileInfo("/input.txt").Length); Console.WriteLine(new FileInfo("input.txt").Length); } }
Transform the following PowerShell implementation into C++, maintaining the same output and logic.
Get-ChildItem input.txt | Select-Object Name,Length Get-ChildItem \input.txt | Select-Object Name,Length
#include <iostream> #include <fstream> std::ios::off_type getFileSize(const char *filename) { std::ifstream f(filename); std::ios::pos_type begin = f.tellg(); f.seekg(0, std::ios::end); std::ios::pos_type end = f.tellg(); return end - begin; } int main() { std::cout << getFileSize("input.txt") << std::end...
Keep all operations the same but rewrite the snippet in Java.
Get-ChildItem input.txt | Select-Object Name,Length Get-ChildItem \input.txt | Select-Object Name,Length
import java.io.File; public class FileSize { public static void main ( String[] args ) { System.out.println("input.txt  : " + new File("input.txt").length() + " bytes"); System.out.println("/input.txt : " + new File("/input.txt").length() + " bytes"); } }
Rewrite this program in Python while keeping its functionality equivalent to the PowerShell version.
Get-ChildItem input.txt | Select-Object Name,Length Get-ChildItem \input.txt | Select-Object Name,Length
import os size = os.path.getsize('input.txt') size = os.path.getsize('/input.txt')
Port the provided PowerShell code into VB while preserving the original functionality.
Get-ChildItem input.txt | Select-Object Name,Length Get-ChildItem \input.txt | Select-Object Name,Length
Option Explicit ---- Sub DisplayFileSize(ByVal Path As String, ByVal Filename As String) Dim i As Long If InStr(Len(Path), Path, "\") = 0 Then Path = Path & "\" End If On Error Resume Next i = FileLen(Path & Filename) If Err.Number = 0 Then Debug.Print "file size: " & CStr(i) & " Bytes" Else ...