langs a-z
This commit is contained in:
parent
db842d013d
commit
d066446780
11389 changed files with 98361 additions and 1020 deletions
21
Task/Input-loop/NetRexx/input-loop-1.netrexx
Normal file
21
Task/Input-loop/NetRexx/input-loop-1.netrexx
Normal 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
|
||||
20
Task/Input-loop/NetRexx/input-loop-2.netrexx
Normal file
20
Task/Input-loop/NetRexx/input-loop-2.netrexx
Normal 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
|
||||
5
Task/Input-loop/OCaml/input-loop-1.ocaml
Normal file
5
Task/Input-loop/OCaml/input-loop-1.ocaml
Normal 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 ->
|
||||
[]
|
||||
12
Task/Input-loop/OCaml/input-loop-2.ocaml
Normal file
12
Task/Input-loop/OCaml/input-loop-2.ocaml
Normal 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 []
|
||||
;;
|
||||
8
Task/Input-loop/OCaml/input-loop-3.ocaml
Normal file
8
Task/Input-loop/OCaml/input-loop-3.ocaml
Normal 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))
|
||||
17
Task/Input-loop/Objeck/input-loop.objeck
Normal file
17
Task/Input-loop/Objeck/input-loop.objeck
Normal 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();
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
7
Task/Input-loop/Oz/input-loop.oz
Normal file
7
Task/Input-loop/Oz/input-loop.oz
Normal 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
|
||||
9
Task/Input-loop/PL-I/input-loop.pli
Normal file
9
Task/Input-loop/PL-I/input-loop.pli
Normal 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;
|
||||
32
Task/Input-loop/Pascal/input-loop.pascal
Normal file
32
Task/Input-loop/Pascal/input-loop.pascal
Normal 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;
|
||||
10
Task/Input-loop/Perl-6/input-loop.pl6
Normal file
10
Task/Input-loop/Perl-6/input-loop.pl6
Normal 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
|
||||
}
|
||||
}
|
||||
17
Task/Input-loop/PureBasic/input-loop.purebasic
Normal file
17
Task/Input-loop/PureBasic/input-loop.purebasic
Normal 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
|
||||
23
Task/Input-loop/REBOL/input-loop.rebol
Normal file
23
Task/Input-loop/REBOL/input-loop.rebol
Normal 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
|
||||
6
Task/Input-loop/Run-BASIC/input-loop.run
Normal file
6
Task/Input-loop/Run-BASIC/input-loop.run
Normal 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
|
||||
2
Task/Input-loop/SNOBOL4/input-loop.sno
Normal file
2
Task/Input-loop/SNOBOL4/input-loop.sno
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
loop output = input :s(loop)
|
||||
end
|
||||
11
Task/Input-loop/Seed7/input-loop.seed7
Normal file
11
Task/Input-loop/Seed7/input-loop.seed7
Normal 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;
|
||||
1
Task/Input-loop/Slate/input-loop.slate
Normal file
1
Task/Input-loop/Slate/input-loop.slate
Normal file
|
|
@ -0,0 +1 @@
|
|||
(File newNamed: 'README') reader sessionDo: [| :input | input lines do: [| :line | inform: line]].
|
||||
9
Task/Input-loop/TUSCRIPT/input-loop.tuscript
Normal file
9
Task/Input-loop/TUSCRIPT/input-loop.tuscript
Normal 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
|
||||
4
Task/Input-loop/UNIX-Shell/input-loop-1.sh
Normal file
4
Task/Input-loop/UNIX-Shell/input-loop-1.sh
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
while read line ; do
|
||||
# examine or do something to the text in the "line" variable
|
||||
echo "$line"
|
||||
done
|
||||
1
Task/Input-loop/UNIX-Shell/input-loop-2.sh
Normal file
1
Task/Input-loop/UNIX-Shell/input-loop-2.sh
Normal file
|
|
@ -0,0 +1 @@
|
|||
cat < /dev/stdin > /dev/stdout
|
||||
1
Task/Input-loop/UNIX-Shell/input-loop-3.sh
Normal file
1
Task/Input-loop/UNIX-Shell/input-loop-3.sh
Normal file
|
|
@ -0,0 +1 @@
|
|||
cat
|
||||
1
Task/Input-loop/UnixPipes/input-loop-1.unixpipes
Normal file
1
Task/Input-loop/UnixPipes/input-loop-1.unixpipes
Normal file
|
|
@ -0,0 +1 @@
|
|||
yes 'A B C D ' | while read x ; do echo -$x- ; done
|
||||
1
Task/Input-loop/UnixPipes/input-loop-2.unixpipes
Normal file
1
Task/Input-loop/UnixPipes/input-loop-2.unixpipes
Normal file
|
|
@ -0,0 +1 @@
|
|||
yes 'A B C D ' | while read -d\ a ; do echo -$a- ; done
|
||||
7
Task/Input-loop/Vala/input-loop.vala
Normal file
7
Task/Input-loop/Vala/input-loop.vala
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
int main() {
|
||||
string? s;
|
||||
while((s = stdin.read_line()) != null) {
|
||||
stdout.printf("%s\n", s);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
7
Task/Input-loop/Visual-Basic-.NET/input-loop.visual
Normal file
7
Task/Input-loop/Visual-Basic-.NET/input-loop.visual
Normal 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue