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-7-bit Path: g2news1.google.com!postnews1.google.com!not-for-mail From: andreatta@mail.chem.sc.edu (Dan Andreatta) Newsgroups: comp.lang.ada Subject: Re: Ada Popularity: Comparison of Ada/Charles with C++ STL (and Perl) Date: 23 Sep 2004 10:12:29 -0700 Organization: http://groups.google.com Message-ID: <338040f8.0409230912.70e3375b@posting.google.com> References: NNTP-Posting-Host: 129.252.151.81 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1095959549 31642 127.0.0.1 (23 Sep 2004 17:12:29 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 23 Sep 2004 17:12:29 +0000 (UTC) Xref: g2news1.google.com comp.lang.ada:4028 Date: 2004-09-23T10:12:29-07:00 List-Id: kevin.cline@gmail.com (Kevin Cline) wrote in message news:... > As promised in the Ada popularity thread, I have taken one of the > Charles examples and reimplemented it in C++. I used only the > standard C++ language and libraries. The Ada/CHARLES main program > body is 118 (non-blank) lines of code, plus an additional 40 lines of > instantiations in eight other specification files, for a total of 158 > lines and 9 files. The C++ implementation is 76 (non-blank) lines of > code in a single file. For grins, I also wrote the program in Perl. > That took 14 lines. > > Summary: > > Ada/Charles 158 lines, 9 files > C++ 76 lines > Perl 14 lines > > You can compare the implementations at > http://www.geocities.com/kc0a/wordcount.html And I write it in Haskell. 14 lines. OK, I cheated, I used GHC libraries. module Main where import Data.FiniteMap import Data.List import System import Char count_words :: [String] -> [(String, Integer)] count_words ws = sortBy comp $ fmToList $ addListToFM_C (+) emptyFM ws' where comp (_,n) (_,m) = compare m n ws' = zip ws [1,1..] main = do args <- getArgs f <- readFile (args!!0) putStr $ show $ take 10 $ count_words (map (map toLower) $ words f)