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.
| Sysop: | Amessyroom |
|---|---|
| Location: | Fayetteville, NC |
| Users: | 54 |
| Nodes: | 6 (0 / 6) |
| Uptime: | 16:23:23 |
| Calls: | 742 |
| Files: | 1,218 |
| D/L today: |
3 files (2,681K bytes) |
| Messages: | 184,405 |
| Posted today: | 1 |