Example of Icon code, please?

Jeff Adams (jeffa@kurz-ai.com)
Tue, 18 Jul 1995 13:27:28 -0400

I've heard some good reports about Icon here, but I still
don't have a good idea about what it *is*. Can someone
tell me, specifically, why I should use Icon over, say,
Perl? As it is, I count word frequencies in Perl with
a simple program like:

---------------------------------------------------------
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