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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!newsfeed.fsmpi.rwth-aachen.de!newsfeed.straub-nv.de!newsfeed.pionier.net.pl!pwr.wroc.pl!news.wcss.wroc.pl!not-for-mail From: Waldek Hebisch Newsgroups: comp.lang.ada Subject: Re: If not Ada, what else... Date: Fri, 21 Aug 2015 23:03:28 +0000 (UTC) Organization: Politechnika Wroclawska Message-ID: References: <8076cbd0-2655-4c98-b70e-cb5f0c32e4ba@googlegroups.com> <5e6cb30b-5f8c-4fed-969e-3941315ecba0@googlegroups.com> <87si87nf8k.fsf@jester.gateway.sonic.net> <87bneuony6.fsf@jester.gateway.sonic.net> NNTP-Posting-Host: hera.math.uni.wroc.pl X-Trace: z-news.wcss.wroc.pl 1440198208 2585 156.17.86.1 (21 Aug 2015 23:03:28 GMT) X-Complaints-To: abuse@news.pwr.wroc.pl NNTP-Posting-Date: Fri, 21 Aug 2015 23:03:28 +0000 (UTC) Cancel-Lock: sha1:o4CKDWUsbsTl38y9wNHadgF3XGg= User-Agent: tin/2.2.1-20140504 ("Tober an Righ") (UNIX) (Linux/4.1.3 (x86_64)) Xref: news.eternal-september.org comp.lang.ada:27562 Date: 2015-08-21T23:03:28+00:00 List-Id: Paul Rubin wrote: > Stefan.Lucks@uni-weimar.de writes: > > http://rosettacode.org/wiki/Hamming_numbers#Ada > That is not a reasonable solution IMHO. It counts upwards > 1,2,3... testing each number for the testing property. Computers now > are fast enough that this can run through a 32-bit count without taking > all day, so it is able to find the 1691th number which is around 2e9. > But the 10000th number is around 3e17 and the Haskell program finds it > basically instantly. The documentation for the Ada program mentions it > would have to use a bignum library to find the millionth Hamming number, > which overlooks the issue that the number is around 5e83 and counting > that far would take essentially forever. The Haskell program gets it in > a few seconds. You could implement the Haskell algorithm in Ada with > a page or two of code but it would be rather tedious. AFAICS iterative version which uses array as a stream buffer is about 20 lines long and quite easy to write. In fact, version which takes allowed prime divisors as paramenter seem to be shorter than versions specialized to 2, 3 and 5. So, Haskell version is smaller but other can be quite small too. -- Waldek Hebisch hebisch@antispam.uni.wroc.pl