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,21 @@
/* NetRexx */
options replace format comments java crossref symbols nobinary
-- Read from default input stream (console) until end of data
lines = ''
lines[0] = 0
lineNo = 0
loop label ioloop forever
inLine = ask
if inLine = null then leave ioloop -- stop on EOF
lineNo = lineNo + 1
lines[0] = lineNo
lines[lineNo] = inLine
end ioloop
loop l_ = 1 to lines[0]
say l_.right(4)':' lines[l_]
end l_
return

View file

@ -0,0 +1,20 @@
/* NetRexx */
options replace format comments java crossref symbols nobinary
-- Read from default input stream (console) until end of data
lines = ''
lines[0] = 0
inScanner = Scanner(System.in)
loop l_ = 1 while inScanner.hasNext()
inLine = inScanner.nextLine()
lines[0] = l_
lines[l_] = inLine
end l_
inScanner.close()
loop l_ = 1 to lines[0]
say l_.right(4)':' lines[l_]
end l_
return

View file

@ -0,0 +1,5 @@
let rec read_lines ic =
try let line = input_line ic in
line :: read_lines ic
with End_of_file ->
[]

View file

@ -0,0 +1,12 @@
let read_line ic =
try Some (input_line ic)
with End_of_file -> None
let read_lines ic =
let rec loop acc =
match read_line ic with
| Some line -> loop (line :: acc)
| None -> List.rev acc
in
loop []
;;

View file

@ -0,0 +1,8 @@
let read_lines f ic =
let rec loop () =
try f(input_line ic); loop()
with End_of_file -> ()
in
loop()
read_lines print_endline (open_in Sys.argv.(1))

View file

@ -0,0 +1,17 @@
use IO;
bundle Default {
class Test {
function : Main(args : System.String[]) ~ Nil {
f := FileReader->New("in.txt");
if(f->IsOpen()) {
string := f->ReadString();
while(string->Size() > 0) {
string->PrintLine();
string := f->ReadString();
};
f->Close();
};
}
}
}

View file

@ -0,0 +1,7 @@
%% Returns a list of lines.
%% Text: an instance of Open.text (a mixin class)
fun {ReadAll Text}
case {Text getS($)} of false then nil
[] Line then Line|{ReadAll Text}
end
end

View file

@ -0,0 +1,9 @@
declare line character (200) varying;
open file (in) title ('/TEXT.DAT,type(text),recsize(200)' );
on endfile (in) stop;
do forever;
get edit (line) (L);
put skip list (line);
end;

View file

@ -0,0 +1,32 @@
{ for stdio }
var
s : string ;
begin
repeat
readln(s);
until s = "" ;
{ for a file }
var
f : text ;
s : string ;
begin
assignfile(f,'foo');
reset(f);
while not eof(f) do
readln(f,s);
closefile(f);
end;

View file

@ -0,0 +1,10 @@
my $handle = open "filename.txt"; # $handle could be $*IN to read from standard input
for $handle.lines -> $line { # iterates the lines of the $handle
# line endings are automatically stripped
for $line.words -> $word { # iterates the words of the line
# are considered words groups of non-whitespace characters
}
}

View file

@ -0,0 +1,17 @@
If OpenConsole()
; file based line wise
If ReadFile(0, "Text.txt")
While Eof(0) = 0
Debug ReadString(0) ; each line until eof
Wend
CloseFile(0)
EndIf
; file based byte wise
If ReadFile(1, "Text.bin")
While Eof(1) = 0
Debug ReadByte(1) ; each byte until eof
Wend
CloseFile(1)
EndIf
EndIf

View file

@ -0,0 +1,23 @@
REBOL [
Title: "Basic Input Loop"
Author: oofoe
Date: 2009-12-06
URL: http://rosettacode.org/wiki/Basic_input_loop
]
; Slurp the whole file in:
x: read %file.txt
; Bring the file in by lines:
x: read/lines %file.txt
; Read in first 10 lines:
x: read/lines/part %file.txt 10
; Read data a line at a time:
f: open/lines %file.txt
while [not tail? f][
print f/1
f: next f ; Advance to next line.
]
close f

View file

@ -0,0 +1,6 @@
open "\testFile.txt" for input as #f
while not(eof(#f))
line input #f, a$
print a$
wend
close #f

View file

@ -0,0 +1,2 @@
loop output = input :s(loop)
end

View file

@ -0,0 +1,11 @@
$ include "seed7_05.s7i";
const proc: main is func
local
var string: line is "";
begin
while hasNext(IN) do
readln(line);
writeln("LINE: " <& line);
end while;
end func;

View file

@ -0,0 +1 @@
(File newNamed: 'README') reader sessionDo: [| :input | input lines do: [| :line | inform: line]].

View file

@ -0,0 +1,9 @@
$$ MODE TUSCRIPT
file="a.txt"
ERROR/STOP OPEN (file,READ,-std-)
ACCESS source: READ/RECORDS/UTF8 $file s,text
LOOP
READ/NEXT/EXIT source
PRINT text
ENDLOOP
ENDACCESS source

View file

@ -0,0 +1,4 @@
while read line ; do
# examine or do something to the text in the "line" variable
echo "$line"
done

View file

@ -0,0 +1 @@
cat < /dev/stdin > /dev/stdout

View file

@ -0,0 +1 @@
cat

View file

@ -0,0 +1 @@
yes 'A B C D ' | while read x ; do echo -$x- ; done

View file

@ -0,0 +1 @@
yes 'A B C D ' | while read -d\ a ; do echo -$a- ; done

View file

@ -0,0 +1,7 @@
int main() {
string? s;
while((s = stdin.read_line()) != null) {
stdout.printf("%s\n", s);
}
return 0;
}

View file

@ -0,0 +1,7 @@
Sub Consume(ByVal stream As IO.StreamReader)
Dim line = stream.ReadLine
Do Until line Is Nothing
Console.WriteLine(line)
line = stream.ReadLine
Loop
End Sub