---------------------------------------------------------
while (<>) {
@words = split(/\s+/, $_);
foreach $word (@words) {
$wordcount{$word}++; # Increment the entry.
}
}
# Now print out all the entries in the %wordcount array.
foreach $word (sort keys(%wordcount)) {
print "$wordcount{$word}\t$word\n";
}
---------------------------------------------------------
Is this easier in Icon? As easy? Can someone submit some Icon
code to demonstrate?
I don't mean to pick on word counting, but I suppose it's
a simple exercise that illustrates some features of a
language that's good at lexical processing.
Thanks.
-- Jeff Adams, Language Modeling Scientist jeffa@kurz-ai.com Kurzweil Applied Intelligence Waltham, MA (617) 893-5151 x339