From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,243dc2fb696a49cd X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!news2.google.com!proxad.net!feeder2-1.proxad.net!news9-e.free.fr!not-for-mail X-Attribution: Jaco Newsgroups: comp.lang.ada Subject: Re: Ada Popularity: Comparison of Ada/Charles with C++ STL (and Perl) References: <338040f8.0409230912.70e3375b@posting.google.com> From: Eric Jacoboni Organization: Rogntutdju & Associates Date: Thu, 23 Sep 2004 21:21:06 +0200 Message-ID: User-Agent: Gnus/5.110003 (No Gnus v0.3) Emacs/21.3.50 (darwin) Cancel-Lock: sha1:tdNUg8G7P9a/QNTgW/Qub1Nix9A= MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit NNTP-Posting-Date: 23 Sep 2004 21:21:08 MEST NNTP-Posting-Host: 81.56.238.119 X-Trace: 1095967268 news9-e.free.fr 18136 81.56.238.119:16620 X-Complaints-To: abuse@proxad.net Xref: g2news1.google.com comp.lang.ada:4038 Date: 2004-09-23T21:21:08+02:00 List-Id: Pascal Obry writes: > And it is just unreadable ! I just can't understand how this is supposed > to work! Agree... What about Ruby ? Much more readable than perl/python, imho. Its inventor claims to be inspired by Ada and Eiffel syntaxes. (i've don't find the equivalent of the perl <> construct, hence the opening of files given at the command line). I've don't managed to reduce the number of lines (it could be done...). count = Hash.new(0) ARGV.each do |a_filename| # for each filename given as argument.. File::open(a_filename) do |lines| # open it lines.each_line do |line| # for each of its lines... for word in line.split (/[^A-Za-z]+/) # get each word count[word.downcase] += 1 # update this word count end # for end # lines.each_line end # File::open end # ARGV.each sorted_count = count.sort do |pair_1, pair_2| # for each (key,value) pair pair_2[1] <=> pair_1[1] # compare their values end nb = 0 sorted_count.each do |word, nb_occ| # print the first 10 results print word, ' -> ', nb_occ, "\n" nb += 1 break if nb >= 10 end # count.each -- �ric Jacoboni, n� il y a 1399410646 secondes