Instruction
stringlengths
45
106
input_code
stringlengths
1
13.7k
output_code
stringlengths
1
13.7k
Rewrite the snippet below in Go so it works the same as the original PowerShell code.
Get-ChildItem input.txt | Select-Object Name,Length Get-ChildItem \input.txt | Select-Object Name,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") }
Rewrite this program in C while keeping its functionality equivalent to the R version.
sizeinwd <- file.info('input.txt')[["size"]] sizeinroot <- file.info('/input.txt')[["size"]]
#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"))...
Change the programming language of this snippet from R to C# without modifying what it does.
sizeinwd <- file.info('input.txt')[["size"]] sizeinroot <- file.info('/input.txt')[["size"]]
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 R to C++ with equivalent syntax and logic.
sizeinwd <- file.info('input.txt')[["size"]] sizeinroot <- file.info('/input.txt')[["size"]]
#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 R snippet.
sizeinwd <- file.info('input.txt')[["size"]] sizeinroot <- file.info('/input.txt')[["size"]]
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 R code into Python without altering its purpose.
sizeinwd <- file.info('input.txt')[["size"]] sizeinroot <- file.info('/input.txt')[["size"]]
import os size = os.path.getsize('input.txt') size = os.path.getsize('/input.txt')
Write a version of this R function in VB with identical behavior.
sizeinwd <- file.info('input.txt')[["size"]] sizeinroot <- file.info('/input.txt')[["size"]]
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 ...
Keep all operations the same but rewrite the snippet in Go.
sizeinwd <- file.info('input.txt')[["size"]] sizeinroot <- file.info('/input.txt')[["size"]]
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 Racket, keeping it the same logically?
#lang racket (file-size "input.txt") (file-size "/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"))...
Please provide an equivalent version of this Racket code in C#.
#lang racket (file-size "input.txt") (file-size "/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 Racket code into C++ without altering its purpose.
#lang racket (file-size "input.txt") (file-size "/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...
Generate an equivalent Java version of this Racket code.
#lang racket (file-size "input.txt") (file-size "/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"); } }
Produce a functionally identical Python code for the snippet given in Racket.
#lang racket (file-size "input.txt") (file-size "/input.txt")
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 Racket, keeping it the same logically?
#lang racket (file-size "input.txt") (file-size "/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 ...
Maintain the same structure and functionality when rewriting this code in Go.
#lang racket (file-size "input.txt") (file-size "/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") }
Ensure the translated C code behaves exactly like the original COBOL snippet.
identification division. program-id. FileInfo. data division. working-storage section. 01 file-name pic x(256). 01 file-size-edited pic zzz,zzz,zzz. 01 file-details. 05 file-size pic x(8) comp-x. 05 file-date. ...
#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 provided COBOL code into C# while preserving the original functionality.
identification division. program-id. FileInfo. data division. working-storage section. 01 file-name pic x(256). 01 file-size-edited pic zzz,zzz,zzz. 01 file-details. 05 file-size pic x(8) comp-x. 05 file-date. ...
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); } }
Ensure the translated C++ code behaves exactly like the original COBOL snippet.
identification division. program-id. FileInfo. data division. working-storage section. 01 file-name pic x(256). 01 file-size-edited pic zzz,zzz,zzz. 01 file-details. 05 file-size pic x(8) comp-x. 05 file-date. ...
#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 COBOL block to Java, preserving its control flow and logic.
identification division. program-id. FileInfo. data division. working-storage section. 01 file-name pic x(256). 01 file-size-edited pic zzz,zzz,zzz. 01 file-details. 05 file-size pic x(8) comp-x. 05 file-date. ...
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"); } }
Write the same algorithm in Python as shown in this COBOL implementation.
identification division. program-id. FileInfo. data division. working-storage section. 01 file-name pic x(256). 01 file-size-edited pic zzz,zzz,zzz. 01 file-details. 05 file-size pic x(8) comp-x. 05 file-date. ...
import os size = os.path.getsize('input.txt') size = os.path.getsize('/input.txt')
Generate an equivalent VB version of this COBOL code.
identification division. program-id. FileInfo. data division. working-storage section. 01 file-name pic x(256). 01 file-size-edited pic zzz,zzz,zzz. 01 file-details. 05 file-size pic x(8) comp-x. 05 file-date. ...
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 COBOL to Go without modifying what it does.
identification division. program-id. FileInfo. data division. working-storage section. 01 file-name pic x(256). 01 file-size-edited pic zzz,zzz,zzz. 01 file-details. 05 file-size pic x(8) comp-x. 05 file-date. ...
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 REXX, keeping it the same logically?
options replace format comments java symbols binary runSample(arg) return -- . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . method fileSize(fn) public static returns double ff = File(fn) fSize = ff.length() return fSize -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~...
#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 the snippet below in C# so it works the same as the original REXX code.
options replace format comments java symbols binary runSample(arg) return -- . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . method fileSize(fn) public static returns double ff = File(fn) fSize = ff.length() return fSize -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~...
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); } }
Keep all operations the same but rewrite the snippet in C++.
options replace format comments java symbols binary runSample(arg) return -- . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . method fileSize(fn) public static returns double ff = File(fn) fSize = ff.length() return fSize -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~...
#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...
Rewrite this program in Java while keeping its functionality equivalent to the REXX version.
options replace format comments java symbols binary runSample(arg) return -- . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . method fileSize(fn) public static returns double ff = File(fn) fSize = ff.length() return fSize -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~...
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 this program into Python but keep the logic exactly as in REXX.
options replace format comments java symbols binary runSample(arg) return -- . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . method fileSize(fn) public static returns double ff = File(fn) fSize = ff.length() return fSize -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~...
import os size = os.path.getsize('input.txt') size = os.path.getsize('/input.txt')
Ensure the translated VB code behaves exactly like the original REXX snippet.
options replace format comments java symbols binary runSample(arg) return -- . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . method fileSize(fn) public static returns double ff = File(fn) fSize = ff.length() return fSize -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~...
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 REXX, keeping it the same logically?
options replace format comments java symbols binary runSample(arg) return -- . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . method fileSize(fn) public static returns double ff = File(fn) fSize = ff.length() return fSize -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~...
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 Ruby.
size = File.size('input.txt') size = File.size('/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"))...
Ensure the translated C# code behaves exactly like the original Ruby snippet.
size = File.size('input.txt') size = File.size('/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); } }
Maintain the same structure and functionality when rewriting this code in C++.
size = File.size('input.txt') size = File.size('/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.
size = File.size('input.txt') size = File.size('/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 Ruby block to Python, preserving its control flow and logic.
size = File.size('input.txt') size = File.size('/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 Ruby.
size = File.size('input.txt') size = File.size('/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 Ruby to Go, same semantics.
size = File.size('input.txt') size = File.size('/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 Scala version.
import java.io.File fun main(args: Array<String>) { val paths = arrayOf("input.txt", "c:\\input.txt") for (path in paths) println("Length of $path is ${File(path).length()} bytes") }
#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 this Scala snippet to C# and keep its semantics consistent.
import java.io.File fun main(args: Array<String>) { val paths = arrayOf("input.txt", "c:\\input.txt") for (path in paths) println("Length of $path is ${File(path).length()} bytes") }
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 programming language of this snippet from Scala to C++ without modifying what it does.
import java.io.File fun main(args: Array<String>) { val paths = arrayOf("input.txt", "c:\\input.txt") for (path in paths) println("Length of $path is ${File(path).length()} bytes") }
#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...
Can you help me rewrite this code in Java instead of Scala, keeping it the same logically?
import java.io.File fun main(args: Array<String>) { val paths = arrayOf("input.txt", "c:\\input.txt") for (path in paths) println("Length of $path is ${File(path).length()} bytes") }
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 an equivalent Python version of this Scala code.
import java.io.File fun main(args: Array<String>) { val paths = arrayOf("input.txt", "c:\\input.txt") for (path in paths) println("Length of $path is ${File(path).length()} bytes") }
import os size = os.path.getsize('input.txt') size = os.path.getsize('/input.txt')
Translate the given Scala code snippet into VB without altering its behavior.
import java.io.File fun main(args: Array<String>) { val paths = arrayOf("input.txt", "c:\\input.txt") for (path in paths) println("Length of $path is ${File(path).length()} bytes") }
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 the snippet below in Go so it works the same as the original Scala code.
import java.io.File fun main(args: Array<String>) { val paths = arrayOf("input.txt", "c:\\input.txt") for (path in paths) println("Length of $path is ${File(path).length()} bytes") }
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 the snippet below in C so it works the same as the original Tcl code.
file size input.txt file size /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"))...
Please provide an equivalent version of this Tcl code in C#.
file size input.txt file size /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 the snippet below in C++ so it works the same as the original Tcl code.
file size input.txt file size /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 following code from Tcl to Java with equivalent syntax and logic.
file size input.txt file size /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 the following code from Tcl to Python, ensuring the logic remains intact.
file size input.txt file size /input.txt
import os size = os.path.getsize('input.txt') size = os.path.getsize('/input.txt')
Change the programming language of this snippet from Tcl to VB without modifying what it does.
file size input.txt file size /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 ...
Rewrite the snippet below in Go so it works the same as the original Tcl code.
file size input.txt file size /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") }
Port the provided Rust code into PHP while preserving the original functionality.
use std::{env, fs, process}; use std::io::{self, Write}; use std::fmt::Display; fn main() { let file_name = env::args().nth(1).unwrap_or_else(|| exit_err("No file name supplied", 1)); let metadata = fs::metadata(file_name).unwrap_or_else(|e| exit_err(e, 2)); println!("Size of file.txt is {} bytes", metada...
<?php echo filesize('input.txt'), "\n"; echo filesize('/input.txt'), "\n"; ?>
Port the following code from Ada to PHP with equivalent syntax and logic.
with Ada.Directories; use Ada.Directories; with Ada.Text_IO; use Ada.Text_IO; procedure Test_File_Size is begin Put_Line (File_Size'Image (Size ("input.txt")) & " bytes"); Put_Line (File_Size'Image (Size ("/input.txt")) & " bytes"); end Test_File_Size;
<?php echo filesize('input.txt'), "\n"; echo filesize('/input.txt'), "\n"; ?>
Write the same algorithm in PHP as shown in this Arturo implementation.
print volume "input.txt" print volume "/input.txt"
<?php echo filesize('input.txt'), "\n"; echo filesize('/input.txt'), "\n"; ?>
Change the programming language of this snippet from AutoHotKey to PHP without modifying what it does.
FileGetSize, FileSize, input.txt   MsgBox, Size of input.txt is %FileSize% bytes FileGetSize, FileSize, \input.txt, K   MsgBox, Size of \input.txt is %FileSize% Kbytes
<?php echo filesize('input.txt'), "\n"; echo filesize('/input.txt'), "\n"; ?>
Can you help me rewrite this code in PHP instead of AWK, keeping it the same logically?
@load "filefuncs" function filesize(name ,fd) { if ( stat(name, fd) == -1) return -1 else return fd["size"] } BEGIN { print filesize("input.txt") print filesize("/input.txt") }
<?php echo filesize('input.txt'), "\n"; echo filesize('/input.txt'), "\n"; ?>
Maintain the same structure and functionality when rewriting this code in PHP.
file% = OPENIN(@dir$+"input.txt") IF file% THEN PRINT "File size = " ; EXT#file% CLOSE #file% ENDIF file% = OPENIN("\input.txt") IF file% THEN PRINT "File size = " ; EXT#file% CLOSE #file% ENDIF
<?php echo filesize('input.txt'), "\n"; echo filesize('/input.txt'), "\n"; ?>
Translate the given Clojure code snippet into PHP without altering its behavior.
(require '[clojure.java.io :as io]) (defn show-size [filename] (println filename "size:" (.length (io/file filename)))) (show-size "input.txt") (show-size "/input.txt")
<?php echo filesize('input.txt'), "\n"; echo filesize('/input.txt'), "\n"; ?>
Translate the given Common_Lisp code snippet into PHP without altering its behavior.
(with-open-file (stream (make-pathname :name "input.txt") :direction :input :if-does-not-exist nil) (print (if stream (file-length stream) 0))) (with-open-file (stream (make-pathname :directory '(:absolute "") :name "input.txt") :direction :input ...
<?php echo filesize('input.txt'), "\n"; echo filesize('/input.txt'), "\n"; ?>
Port the provided D code into PHP while preserving the original functionality.
import std.file, std.stdio, std.path, std.file, std.stream, std.mmfile; void main() { immutable fileName = "file_size.exe"; try { writefln("File '%s' has size:", fileName); writefln("%10d bytes by std.file.getSize (function)", std.file.getSize(fileName)); writ...
<?php echo filesize('input.txt'), "\n"; echo filesize('/input.txt'), "\n"; ?>
Convert this Delphi snippet to PHP and keep its semantics consistent.
program SizeOfFile; uses SysUtils; function CheckFileSize(const aFilename: string): Integer; var lFile: file of Byte; begin AssignFile(lFile, aFilename); FileMode := 0; Reset(lFile); Result := FileSize(lFile); CloseFile(lFile); end; begin Writeln('input.txt ', CheckFileSize('input.txt')); Writeln(...
<?php echo filesize('input.txt'), "\n"; echo filesize('/input.txt'), "\n"; ?>
Port the following code from Elixir to PHP with equivalent syntax and logic.
IO.puts File.stat!("input.txt").size IO.puts File.stat!("/input.txt").size
<?php echo filesize('input.txt'), "\n"; echo filesize('/input.txt'), "\n"; ?>
Write a version of this Erlang function in PHP with identical behavior.
-module(file_size). -export([file_size/0]). -include_lib("kernel/include/file.hrl"). file_size() -> print_file_size("input.txt"), print_file_size("/input.txt"). print_file_size(Filename) -> case file:read_file_info(Filename) of {ok, FileInfo} -> io:format("~s ~p~n", [Filename, FileInfo#file_info.si...
<?php echo filesize('input.txt'), "\n"; echo filesize('/input.txt'), "\n"; ?>
Rewrite this program in PHP 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...
<?php echo filesize('input.txt'), "\n"; echo filesize('/input.txt'), "\n"; ?>
Convert the following code from Factor to PHP, ensuring the logic remains intact.
"input.txt" file-info size>> . 1321 "file-does-not-exist.txt" file-info size>> "Unix system call ``stat'' failed:"...
<?php echo filesize('input.txt'), "\n"; echo filesize('/input.txt'), "\n"; ?>
Translate the given Forth code snippet into PHP without altering its 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
<?php echo filesize('input.txt'), "\n"; echo filesize('/input.txt'), "\n"; ?>
Write the same code in PHP as shown below 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...
<?php echo filesize('input.txt'), "\n"; echo filesize('/input.txt'), "\n"; ?>
Change the programming language of this snippet from Groovy to PHP without modifying what it does.
println new File('index.txt').length(); println new File('/index.txt').length();
<?php echo filesize('input.txt'), "\n"; echo filesize('/input.txt'), "\n"; ?>
Generate an equivalent PHP version of this Haskell code.
import System.IO printFileSize filename = withFile filename ReadMode hFileSize >>= print main = mapM_ printFileSize ["input.txt", "/input.txt"]
<?php echo filesize('input.txt'), "\n"; echo filesize('/input.txt'), "\n"; ?>
Ensure the translated PHP code behaves exactly like the original J snippet.
require 'files' fsize 'input.txt';'/input.txt'
<?php echo filesize('input.txt'), "\n"; echo filesize('/input.txt'), "\n"; ?>
Produce a language-to-language conversion: from Julia to PHP, same semantics.
println(filesize("input.txt")) println(filesize("/input.txt"))
<?php echo filesize('input.txt'), "\n"; echo filesize('/input.txt'), "\n"; ?>
Convert this Lua block to PHP, preserving its control flow 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
<?php echo filesize('input.txt'), "\n"; echo filesize('/input.txt'), "\n"; ?>
Please provide an equivalent version of this Mathematica code in PHP.
FileByteCount["input.txt"] FileByteCount[FileNameJoin[{$RootDirectory, "input.txt"}]]
<?php echo filesize('input.txt'), "\n"; echo filesize('/input.txt'), "\n"; ?>
Keep all operations the same but rewrite the snippet in PHP.
d1 = dir('input.txt'); d2 = dir('/input.txt'); fprintf('Size of input.txt is fprintf('Size of /input.txt is
<?php echo filesize('input.txt'), "\n"; echo filesize('/input.txt'), "\n"; ?>
Produce a functionally identical PHP code for the snippet given in Nim.
import os echo getFileSize "input.txt" echo getFileSize "/input.txt"
<?php echo filesize('input.txt'), "\n"; echo filesize('/input.txt'), "\n"; ?>
Transform the following OCaml implementation into PHP, maintaining the same output 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" ;;
<?php echo filesize('input.txt'), "\n"; echo filesize('/input.txt'), "\n"; ?>
Convert the following code from Perl to PHP, ensuring the logic remains intact.
my $size1 = -s 'input.txt'; my $size2 = -s '/input.txt';
<?php echo filesize('input.txt'), "\n"; echo filesize('/input.txt'), "\n"; ?>
Write the same code in PHP as shown below in PowerShell.
Get-ChildItem input.txt | Select-Object Name,Length Get-ChildItem \input.txt | Select-Object Name,Length
<?php echo filesize('input.txt'), "\n"; echo filesize('/input.txt'), "\n"; ?>
Produce a functionally identical PHP code for the snippet given in R.
sizeinwd <- file.info('input.txt')[["size"]] sizeinroot <- file.info('/input.txt')[["size"]]
<?php echo filesize('input.txt'), "\n"; echo filesize('/input.txt'), "\n"; ?>
Translate the given Racket code snippet into PHP without altering its behavior.
#lang racket (file-size "input.txt") (file-size "/input.txt")
<?php echo filesize('input.txt'), "\n"; echo filesize('/input.txt'), "\n"; ?>
Rewrite the snippet below in PHP so it works the same as the original COBOL code.
identification division. program-id. FileInfo. data division. working-storage section. 01 file-name pic x(256). 01 file-size-edited pic zzz,zzz,zzz. 01 file-details. 05 file-size pic x(8) comp-x. 05 file-date. ...
<?php echo filesize('input.txt'), "\n"; echo filesize('/input.txt'), "\n"; ?>
Translate the given REXX code snippet into PHP without altering its behavior.
options replace format comments java symbols binary runSample(arg) return -- . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . method fileSize(fn) public static returns double ff = File(fn) fSize = ff.length() return fSize -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~...
<?php echo filesize('input.txt'), "\n"; echo filesize('/input.txt'), "\n"; ?>
Convert this Ruby snippet to PHP and keep its semantics consistent.
size = File.size('input.txt') size = File.size('/input.txt')
<?php echo filesize('input.txt'), "\n"; echo filesize('/input.txt'), "\n"; ?>
Generate a PHP translation of this Scala snippet without changing its computational steps.
import java.io.File fun main(args: Array<String>) { val paths = arrayOf("input.txt", "c:\\input.txt") for (path in paths) println("Length of $path is ${File(path).length()} bytes") }
<?php echo filesize('input.txt'), "\n"; echo filesize('/input.txt'), "\n"; ?>
Port the following code from Tcl to PHP with equivalent syntax and logic.
file size input.txt file size /input.txt
<?php echo filesize('input.txt'), "\n"; echo filesize('/input.txt'), "\n"; ?>
Maintain the same structure and functionality when rewriting this code in Rust.
#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...
use std::{env, fs, process}; use std::io::{self, Write}; use std::fmt::Display; fn main() { let file_name = env::args().nth(1).unwrap_or_else(|| exit_err("No file name supplied", 1)); let metadata = fs::metadata(file_name).unwrap_or_else(|e| exit_err(e, 2)); println!("Size of file.txt is {} bytes", metada...
Port the following code from Go to Rust with equivalent syntax and logic.
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") }
use std::{env, fs, process}; use std::io::{self, Write}; use std::fmt::Display; fn main() { let file_name = env::args().nth(1).unwrap_or_else(|| exit_err("No file name supplied", 1)); let metadata = fs::metadata(file_name).unwrap_or_else(|e| exit_err(e, 2)); println!("Size of file.txt is {} bytes", metada...
Translate the given Rust code snippet into Python without altering its behavior.
use std::{env, fs, process}; use std::io::{self, Write}; use std::fmt::Display; fn main() { let file_name = env::args().nth(1).unwrap_or_else(|| exit_err("No file name supplied", 1)); let metadata = fs::metadata(file_name).unwrap_or_else(|e| exit_err(e, 2)); println!("Size of file.txt is {} bytes", metada...
import os size = os.path.getsize('input.txt') size = os.path.getsize('/input.txt')
Rewrite this program in Rust while keeping its functionality equivalent to the C# version.
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); } }
use std::{env, fs, process}; use std::io::{self, Write}; use std::fmt::Display; fn main() { let file_name = env::args().nth(1).unwrap_or_else(|| exit_err("No file name supplied", 1)); let metadata = fs::metadata(file_name).unwrap_or_else(|e| exit_err(e, 2)); println!("Size of file.txt is {} bytes", metada...
Rewrite the snippet below in Rust so it works the same as the original Java code.
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"); } }
use std::{env, fs, process}; use std::io::{self, Write}; use std::fmt::Display; fn main() { let file_name = env::args().nth(1).unwrap_or_else(|| exit_err("No file name supplied", 1)); let metadata = fs::metadata(file_name).unwrap_or_else(|e| exit_err(e, 2)); println!("Size of file.txt is {} bytes", metada...
Write a version of this Rust function in VB with identical behavior.
use std::{env, fs, process}; use std::io::{self, Write}; use std::fmt::Display; fn main() { let file_name = env::args().nth(1).unwrap_or_else(|| exit_err("No file name supplied", 1)); let metadata = fs::metadata(file_name).unwrap_or_else(|e| exit_err(e, 2)); println!("Size of file.txt is {} bytes", metada...
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 C to Rust with equivalent syntax and logic.
#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"))...
use std::{env, fs, process}; use std::io::{self, Write}; use std::fmt::Display; fn main() { let file_name = env::args().nth(1).unwrap_or_else(|| exit_err("No file name supplied", 1)); let metadata = fs::metadata(file_name).unwrap_or_else(|e| exit_err(e, 2)); println!("Size of file.txt is {} bytes", metada...
Rewrite this program in C# while keeping its functionality equivalent to the Ada version.
with Aws.Client, Aws.Messages, Aws.Response, Aws.Resources, Aws.Url; with Dom.Readers, Dom.Core, Dom.Core.Documents, Dom.Core.Nodes, Dom.Core.Attrs; with Input_Sources.Strings, Unicode, Unicode.Ces.Utf8; with Ada.Strings.Unbounded, Ada.Text_IO, Ada.Command_Line; with Ada.Containers.Vectors; use Aws.Client, Aws.Messag...
using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; using System.Net; class Program { static List<string> GetTitlesFromCategory(string category) { string searchQueryFormat = "http: List<string> results = new List<string>(); string cmconti...
Rewrite the snippet below in C so it works the same as the original Ada code.
with Aws.Client, Aws.Messages, Aws.Response, Aws.Resources, Aws.Url; with Dom.Readers, Dom.Core, Dom.Core.Documents, Dom.Core.Nodes, Dom.Core.Attrs; with Input_Sources.Strings, Unicode, Unicode.Ces.Utf8; with Ada.Strings.Unbounded, Ada.Text_IO, Ada.Command_Line; with Ada.Containers.Vectors; use Aws.Client, Aws.Messag...
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <curl/curl.h> #include "wren.h" struct MemoryStruct { char *memory; size_t size; }; static size_t WriteMemoryCallback(void *contents, size_t size, size_t nmemb, void *userp) { size_t realsize = size * nmemb; struct MemoryStruct *m...
Convert the following code from Ada to Go, ensuring the logic remains intact.
with Aws.Client, Aws.Messages, Aws.Response, Aws.Resources, Aws.Url; with Dom.Readers, Dom.Core, Dom.Core.Documents, Dom.Core.Nodes, Dom.Core.Attrs; with Input_Sources.Strings, Unicode, Unicode.Ces.Utf8; with Ada.Strings.Unbounded, Ada.Text_IO, Ada.Command_Line; with Ada.Containers.Vectors; use Aws.Client, Aws.Messag...
package main import ( "encoding/xml" "fmt" "io" "net/http" "net/url" ) const language = "Go" var baseQuery = "http: "&format=xml&list=categorymembers&cmlimit=100" func req(u string, foundCm func(string)) string { resp, err := http.Get(u) if err != nil { fmt.Println(err) ...
Convert this Ada block to Python, preserving its control flow and logic.
with Aws.Client, Aws.Messages, Aws.Response, Aws.Resources, Aws.Url; with Dom.Readers, Dom.Core, Dom.Core.Documents, Dom.Core.Nodes, Dom.Core.Attrs; with Input_Sources.Strings, Unicode, Unicode.Ces.Utf8; with Ada.Strings.Unbounded, Ada.Text_IO, Ada.Command_Line; with Ada.Containers.Vectors; use Aws.Client, Aws.Messag...
from operator import attrgetter from typing import Iterator import mwclient URL = 'www.rosettacode.org' API_PATH = '/mw/' def unimplemented_tasks(language: str, *, url: str, api_path: str) -> Iterator[str]: site = mwclient.Site(url, p...
Write the same code in VB as shown below in Ada.
with Aws.Client, Aws.Messages, Aws.Response, Aws.Resources, Aws.Url; with Dom.Readers, Dom.Core, Dom.Core.Documents, Dom.Core.Nodes, Dom.Core.Attrs; with Input_Sources.Strings, Unicode, Unicode.Ces.Utf8; with Ada.Strings.Unbounded, Ada.Text_IO, Ada.Command_Line; with Ada.Containers.Vectors; use Aws.Client, Aws.Messag...
Set http= CreateObject("WinHttp.WinHttpRequest.5.1") Set oDic = WScript.CreateObject("scripting.dictionary") start="https://rosettacode.org" Const lang="VBScript" Dim oHF gettaskslist "about:/wiki/Category:Programming_Tasks" ,True print odic.Count gettaskslist "about:/wiki/Category:Draft_Programming_Tasks",True prin...
Generate an equivalent C version of this AutoHotKey code.
#NoEnv  #SingleInstance force  SetBatchLines, -1  SetControlDelay, 0  AutoExec: Gui, Add, DDL, x10 y10 w270 r20 vlngStr  Gui, Add, Button, x290 y10 gShowLng, Show Unimplemented  Gui, Add, ListView, x10 y36 w400 h300 vcatLst gOnLV, Unimplemented  Gui, Add, StatusBar, vsbStr,  Gui, Show, , RosettaCode unimpl...
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <curl/curl.h> #include "wren.h" struct MemoryStruct { char *memory; size_t size; }; static size_t WriteMemoryCallback(void *contents, size_t size, size_t nmemb, void *userp) { size_t realsize = size * nmemb; struct MemoryStruct *m...
Produce a language-to-language conversion: from AutoHotKey to C#, same semantics.
#NoEnv  #SingleInstance force  SetBatchLines, -1  SetControlDelay, 0  AutoExec: Gui, Add, DDL, x10 y10 w270 r20 vlngStr  Gui, Add, Button, x290 y10 gShowLng, Show Unimplemented  Gui, Add, ListView, x10 y36 w400 h300 vcatLst gOnLV, Unimplemented  Gui, Add, StatusBar, vsbStr,  Gui, Show, , RosettaCode unimpl...
using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; using System.Net; class Program { static List<string> GetTitlesFromCategory(string category) { string searchQueryFormat = "http: List<string> results = new List<string>(); string cmconti...
Write the same algorithm in Python as shown in this AutoHotKey implementation.
#NoEnv  #SingleInstance force  SetBatchLines, -1  SetControlDelay, 0  AutoExec: Gui, Add, DDL, x10 y10 w270 r20 vlngStr  Gui, Add, Button, x290 y10 gShowLng, Show Unimplemented  Gui, Add, ListView, x10 y36 w400 h300 vcatLst gOnLV, Unimplemented  Gui, Add, StatusBar, vsbStr,  Gui, Show, , RosettaCode unimpl...
from operator import attrgetter from typing import Iterator import mwclient URL = 'www.rosettacode.org' API_PATH = '/mw/' def unimplemented_tasks(language: str, *, url: str, api_path: str) -> Iterator[str]: site = mwclient.Site(url, p...
Translate this program into VB but keep the logic exactly as in AutoHotKey.
#NoEnv  #SingleInstance force  SetBatchLines, -1  SetControlDelay, 0  AutoExec: Gui, Add, DDL, x10 y10 w270 r20 vlngStr  Gui, Add, Button, x290 y10 gShowLng, Show Unimplemented  Gui, Add, ListView, x10 y36 w400 h300 vcatLst gOnLV, Unimplemented  Gui, Add, StatusBar, vsbStr,  Gui, Show, , RosettaCode unimpl...
Set http= CreateObject("WinHttp.WinHttpRequest.5.1") Set oDic = WScript.CreateObject("scripting.dictionary") start="https://rosettacode.org" Const lang="VBScript" Dim oHF gettaskslist "about:/wiki/Category:Programming_Tasks" ,True print odic.Count gettaskslist "about:/wiki/Category:Draft_Programming_Tasks",True prin...