langs a-z

This commit is contained in:
Ingy döt Net 2013-04-10 22:43:41 -07:00
parent db842d013d
commit d066446780
11389 changed files with 98361 additions and 1020 deletions

View file

@ -0,0 +1,27 @@
/* NetRexx */
options replace format comments java crossref symbols nobinary
import java.nio.
parse arg infileName outfileName .
if infileName = '' | infileName.length = 0 then infileName = 'data/input.txt'
if outfileName = '' | outfileName.length = 0 then outfileName = 'data/output.txt'
binaryCopy(infileName, outfileName)
return
method binaryCopy(infileName, outfileName) public static
do
infile = Paths.get('.', [String infileName])
outfile = Paths.get('.', [String outfileName])
fileOctets = Files.readAllBytes(infile)
Files.write(outfile, fileOctets, [StandardOpenOption.WRITE, StandardOpenOption.CREATE])
catch ioex = IOException
ioex.printStackTrace()
end
return

View file

@ -0,0 +1,13 @@
let () =
let ic = open_in "input.txt" in
let oc = open_out "output.txt" in
try
while true do
let s = input_line ic in
output_string oc s;
output_char oc '\n';
done
with End_of_file ->
close_in ic;
close_out oc;
;;

View file

@ -0,0 +1,12 @@
let () =
let ic = open_in "input.txt" in
let oc = open_out "output.txt" in
try
while true do
let c = input_char ic in
output_char oc c
done
with End_of_file ->
close_in ic;
close_out oc;
;;

View file

@ -0,0 +1,20 @@
use IO;
bundle Default {
class Test {
function : Main(args : String[]) ~ Nil {
len := File->Size("input.txt");
buffer := Byte->New[len];
in := FileReader->New("input.txt");
if(in->IsOpen() <> Nil) {
in->ReadBuffer(0, len, buffer);
out := FileWriter->New("output.txt");
if(out->IsOpen() <> Nil) {
out->WriteBuffer(0, len, buffer);
out->Close();
};
in->Close();
};
}
}
}

View file

@ -0,0 +1,10 @@
uses
classes;
begin
with TFileStream.Create('input.txt', fmOpenRead) do
try
SaveToFile('output.txt');
finally
Free;
end;
end;

View file

@ -0,0 +1,3 @@
NSData *data = [NSData dataWithContentsOfFile:@"input.txt"];
[data writeToFile:@"output.txt" atomically:YES];

View file

@ -0,0 +1 @@
COPY-LOB FROM FILE "input.txt" TO FILE "output.txt".

View file

@ -0,0 +1,17 @@
declare
class TextFile from Open.file Open.text end
In = {New TextFile init(name:"input.txt")}
Out = {New TextFile init(name:"output.txt" flags:[write text create truncate])}
proc {CopyAll In Out}
case {In getS($)} of false then skip
[] Line then
{Out putS(Line)}
{CopyAll In Out}
end
end
in
{CopyAll In Out}
{Out close}
{In close}

View file

@ -0,0 +1,2 @@
f=read("filename.in");
write("filename.out", f);

View file

@ -0,0 +1,8 @@
declare in file, out file;
open file (in) title ('/INPUT.TXT,type(text),recsize(100)') input;
open file (out) title ('/OUTPUT.TXT,type(text),recsize(100) output;
do forever;
get file (in) edit (line) (L);
put file (out) edit (line) (A);
end;

View file

@ -0,0 +1,5 @@
my $in = open "input.txt";
my $out = open "output.txt", :w;
for $in.lines -> $line {
$out.say($line);
}

View file

@ -0,0 +1 @@
(open "output.txt", :w).print(slurp "input.txt")

View file

@ -0,0 +1,6 @@
lvars i_stream = discin('input.txt');
lvars o_stream = discout('output.txt');
lvars c;
while (i_stream() ->> c) /= termin do
o_stream(c);
endwhile;

View file

@ -0,0 +1,7 @@
lvars i_file = sysopen('input.txt', 0, true);
lvars o_file = syscreate('output.txt', 1, true);
lvars buff = inits(4096);
lvars i;
while (sysread(i_file, buff, length(buff)) ->> i) > 0 do
syswrite(o_file, buff, i);
endwhile;

View file

@ -0,0 +1 @@
Get-Content $PWD\input.txt | Out-File $PWD\output.txt

View file

@ -0,0 +1 @@
Get-Content $PWD\input.txt | Set-Content $PWD\output.txt

View file

@ -0,0 +1 @@
CopyFile("input.txt","output.txt")

View file

@ -0,0 +1,13 @@
in = ReadFile(#PB_Any,"input.txt")
If in
out = CreateFile(#PB_Any,"output.txt")
If out
Define MyLine$
While Not Eof(in)
MyLine$ = ReadString(in)
WriteString(out,MyLine$)
Wend
CloseFile(out)
EndIf
CloseFile(in)
EndIf

View file

@ -0,0 +1,14 @@
If ReadFile(0,"input.txt")
Define MyLine$, *Buffer, length
length=FileSize("input.txt")
*Buffer = AllocateMemory(length)
If *Buffer
If OpenFile(1,"output.txt")
ReadData(0, *Buffer, length)
WriteData(1, *Buffer, length)
CloseFile(1)
EndIf
FreeMemory(*Buffer)
EndIf
CloseFile(0)
EndIf

View file

@ -0,0 +1,11 @@
Sub WriteToFile(input As FolderItem, output As FolderItem)
Dim tis As TextInputStream
Dim tos As TextOutputStream
tis = tis.Open(input)
tos = tos.Create(output)
While Not tis.EOF
tos.WriteLine(tis.ReadLine)
Wend
tis.Close
tos.Close
End Sub

View file

@ -0,0 +1,7 @@
write %output.txt read %input.txt
; No line translations:
write/binary %output.txt read/binary %input.txt
; Save a web page:
write/binary %output.html read http://rosettacode.org

View file

@ -0,0 +1,15 @@
$INCLUDE "rapidq.inc"
DIM File1 AS QFileStream
DIM File2 AS QFileStream
File1.Open("input.txt", fmOpenRead)
File2.Open("output.txt", fmCreate)
WHILE NOT File1.EOF
data$ = File1.ReadLine
File2.WriteLine(data$)
WEND
File1.Close
File2.Close

View file

@ -0,0 +1,12 @@
$INCLUDE "rapidq.inc"
DIM File1 AS QFileStream
DIM File2 AS QFileStream
File1.Open("input.txt", fmOpenRead)
File2.Open("output.txt", fmCreate)
File2.CopyFrom(File1, 0)
File1.Close
File2.Close

View file

@ -0,0 +1 @@
'input.txt' read 'output.txt' write

View file

@ -0,0 +1,2 @@
with files'
here dup "input.txt" slurp "output.txt" spew

View file

@ -0,0 +1,18 @@
open "input.txt" for input as #in
fileLen = LOF(#in) 'Length Of File
fileData$ = input$(#in, fileLen) 'read entire file
close #in
open "output.txt" for output as #out
print #out, fileData$ 'write entire fie
close #out
end
' or directly with no intermediate fileData$
open "input.txt" for input as #in
open "output.txt" for output as #out
fileLen = LOF(#in) 'Length Of File
print #out, input$(#in, fileLen) 'entire file
close #in
close #out

View file

@ -0,0 +1,4 @@
input(.input,5,,'input.txt')
output(.output,6,,'output.txt')
while output = input :s(while)
end

View file

@ -0,0 +1,7 @@
$ include "seed7_05.s7i";
include "osfiles.s7i";
const proc: main is func
begin
copyFile("input.txt", "output.txt");
end func;

View file

@ -0,0 +1,3 @@
(File newNamed: 'input.txt' &mode: File Read) sessionDo: [| :in |
(File newNamed: 'output.txt' &mode: File CreateWrite) sessionDo: [| :out |
in >> out]]

View file

@ -0,0 +1,10 @@
fun copyFile (from, to) =
let
val instream = TextIO.openIn from
val outstream = TextIO.openOut to
val () = TextIO.output (outstream, TextIO.inputAll instream)
val () = TextIO.closeIn instream
val () = TextIO.closeOut outstream
in
true
end handle _ => false;

View file

@ -0,0 +1,22 @@
( source dest -- )
{
value| source dest size buffer |
{
{
[ "W" file.open to dest ] is open-dest
[ "R" file.open to source ] is open-source
[ open-dest open-source ]
} is open-files
{
[ source file.size to size ] is obtain-size
[ size malloc to buffer ] is allocate-buffer
[ obtain-size allocate-buffer ]
} is create-buffer
[ source dest and 0 <> ] is check
[ open-files create-buffer check ]
} is prepare
[ source buffer size file.read drop ] is read-source
[ dest buffer size file.write drop ] is write-dest
[ source file.close dest file.close ] is close-files
[ prepare [ read-source write-dest close-files ] ifTrue ]
} is copy-file

View file

@ -0,0 +1,4 @@
[ ( source dest -- )
swap file.slurp dup 0 <>
[ >r "W" file.open dup r> string.getLength file.write drop file.close ] ifTrue
] is copy-file

View file

@ -0,0 +1 @@
" input.txt" " output.txt" copy-file

View file

@ -0,0 +1,4 @@
#!/bin/sh
while IFS= read -r a; do
printf '%s\n' "$a"
done <input.txt >output.txt

View file

@ -0,0 +1,2 @@
#!/bin/sh
cat input.txt >output.txt

View file

@ -0,0 +1,2 @@
#!/bin/sh
cp input.txt output.txt

View file

@ -0,0 +1,5 @@
#import std
#executable ('parameterized','')
fileio = ~command.files; &h.path.&h:= 'output.txt'!

View file

@ -0,0 +1 @@
CreateObject("Scripting.FileSystemObject").OpenTextFile("output.txt",2,-2).Write CreateObject("Scripting.FileSystemObject").OpenTextFile("input.txt", 1, -2).ReadAll

View file

@ -0,0 +1,3 @@
File_Open("input.txt")
File_Save_As("output.txt", NOMSG)
Buf_Close(NOMSG)

View file

@ -0,0 +1,17 @@
'byte copy
My.Computer.FileSystem.WriteAllBytes("output.txt", _
My.Computer.FileSystem.ReadAllBytes("input.txt"), False)
'text copy
Using input = IO.File.OpenText("input.txt"), _
output As New IO.StreamWriter(IO.File.OpenWrite("output.txt"))
output.Write(input.ReadToEnd)
End Using
'Line by line text copy
Using input = IO.File.OpenText("input.txt"), _
output As New IO.StreamWriter(IO.File.OpenWrite("output.txt"))
Do Until input.EndOfStream
output.WriteLine(input.ReadLine)
Loop
End Using

View file

@ -0,0 +1,15 @@
include c:\cxpl\codes;
int I, C;
char IntermediateVariable;
[IntermediateVariable:= GetHp;
I:= 0;
repeat C:= ChIn(1);
IntermediateVariable(I):= C;
I:= I+1;
until C = $1A; \EOF
I:= 0;
repeat C:= IntermediateVariable(I);
I:= I+1;
ChOut(0, C);
until C = $1A; \EOF
]