Input/Output for lines of text: Difference between revisions

Rename Perl 6 -> Raku, alphabetize, minor clean-up
(Add Factor)
(Rename Perl 6 -> Raku, alphabetize, minor clean-up)
Line 152:
 
readln drop [ do-stuff ] each-line</lang>
 
=={{header|Free Pascal}}==
This requires FPC – the FreePascal compiler – to be in a configuration enabling the use ob <tt>object</tt>s.
<lang pascal>program head(input, output, stdErr);
 
type
obj = object
public
procedure method(const s: string); static;
end;
 
procedure obj.method(const s: string);
begin
writeLn(s);
end;
 
var
numberOfLines: integer;
line: string;
begin
readLn(numberOfLines);
for numberOfLines := numberOfLines downto 1 do
begin
readLn(line);
obj.method(line);
end;
end.</lang>
 
=={{header|FreeBASIC}}==
Line 183 ⟶ 211:
Pack my Box with 5 dozen liquor jugs
</pre>
 
=={{header|Free Pascal}}==
This requires FPC – the FreePascal compiler – to be in a configuration enabling the use ob <tt>object</tt>s.
<lang pascal>program head(input, output, stdErr);
 
type
obj = object
public
procedure method(const s: string); static;
end;
 
procedure obj.method(const s: string);
begin
writeLn(s);
end;
 
var
numberOfLines: integer;
line: string;
begin
readLn(numberOfLines);
for numberOfLines := numberOfLines downto 1 do
begin
readLn(line);
obj.method(line);
end;
end.</lang>
 
=={{header|Go}}==
Line 490:
 
sub do_stuff { print $_[0] }</lang>
 
=={{header|Perl 6}}==
 
Short version:
 
<lang perl6>say get for ^get;</lang>
 
Verbose version:
 
<lang perl6>sub do-stuff ($line) {
say $line;
}
my $n = +get;
for ^$n {
my $line = get;
do-stuff $line;
}</lang>
 
=={{header|Phix}}==
Line 558 ⟶ 540:
# ./script file.txt
</lang>
 
=={{header|Python}}==
<lang python>try: input = raw_input
except: pass
 
def do_stuff(words):
print(words)
 
linecount = int(input())
for x in range(linecount):
line = input()
do_stuff(line)</lang>
 
=={{header|Prolog}}==
Line 612 ⟶ 582:
3 ?-
</pre>
 
=={{header|Python}}==
<lang python>try: input = raw_input
except: pass
 
def do_stuff(words):
print(words)
 
linecount = int(input())
for x in range(linecount):
line = input()
do_stuff(line)</lang>
 
=={{header|Racket}}==
Line 627 ⟶ 609:
(for ([i (in-range line-count)])
(do-stuff (read-line)))</lang>
 
=={{header|Raku}}==
(formerly Perl 6)
 
Short version:
 
<lang perl6>say get for ^get;</lang>
 
Verbose version:
 
<lang perl6>sub do-stuff ($line) {
say $line;
}
my $n = +get;
for ^$n {
my $line = get;
do-stuff $line;
}</lang>
 
=={{header|REXX}}==
Line 705 ⟶ 706:
}
}</lang>
 
=={{header|Tcl}}==
<lang tcl>proc do_stuff {line} {
10,333

edits