Sysop: | Amessyroom |
---|---|
Location: | Fayetteville, NC |
Users: | 27 |
Nodes: | 6 (0 / 6) |
Uptime: | 38:27:34 |
Calls: | 631 |
Calls today: | 2 |
Files: | 1,187 |
D/L today: |
22 files (29,767K bytes) |
Messages: | 173,687 |
On 2024-10-09 02:27, Kerr-Mudd, John wrote:
On Wed, 9 Oct 2024 07:12:49 -0000 (UTC)
p.dean@invalid.net (Peter Dean) wrote:
In alt.folklore.computers Lawrence D'Oliveiro <ldo@nz.invalid> wrote:Perl wins! -much more obscu^w shorter
On Tue, 8 Oct 2024 19:53:39 -0600, lar3ryca wrote:
#!/usr/bin/rexx
/* Show only one copy of each line in a whole file */
seen. = 0
Do While Lines() > 0
Parse Pull this_line
If seen.this_line Then Iterate
seen.this_line = 1
Say this_line
end
#!/usr/bin/python3
# Show only one copy of each line in a whole file
import sys
seen = set()
for line in sys.stdin :
if not line in seen :
sys.stdout.write(line)
seen.add(line)
#!/usr/bin/perl
my %seen;
while (<>) {
if (!$seen{$_}) {
$seen{$_}++;
print;
}
}
Good to know that other languages can do it, even if _I_ can't wrap my
head around them.