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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no 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!.POSTED!not-for-mail From: Georg Bauhaus Newsgroups: comp.lang.ada Subject: Re: If not Ada, what else... Date: Thu, 30 Jul 2015 09:38:43 +0200 Organization: A noiseless patient Spider Message-ID: References: <7a29d3e9-d1bd-4f4a-b1a6-14d3e1a83a4d@googlegroups.com> <87mvz36fen.fsf@jester.gateway.sonic.net> <2215b44f-8a89-47c6-a4c4-52b74d2dac45@googlegroups.com> <9e492c82-868d-43d3-a18a-38274400e337@googlegroups.com> <40184feb-4053-4ac3-8eaa-c3bd9cd8a77c@googlegroups.com> <10272577-945f-4682-85bc-8ad47f3653ae@googlegroups.com> <87si8i81k2.fsf@atmarama.net> <8076cbd0-2655-4c98-b70e-cb5f0c32e4ba@googlegroups.com> <5e6cb30b-5f8c-4fed-969e-3941315ecba0@googlegroups.com> <87si87nf8k.fsf@jester.gateway.sonic.net> <87oaiumdfy.fsf@jester.gateway.sonic.net> Reply-To: nonlegitur@futureapps.de Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Thu, 30 Jul 2015 07:37:06 +0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="56de631a3d8648337a6b4928346548b8"; logging-data="10623"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19VcfbXTa5LvAhft/c2Cm7jnTdRvtjvSy0=" User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 In-Reply-To: <87oaiumdfy.fsf@jester.gateway.sonic.net> Cancel-Lock: sha1:r/N9yvsE27tJ2uKMRH28lNUvjFY= Xref: news.eternal-september.org comp.lang.ada:27176 Date: 2015-07-30T09:38:43+02:00 List-Id: On 30.07.15 07:17, Paul Rubin wrote: > Basically the recursive call to "mth" has to > return a value that gets added to y, which means the stack frame can't > get released til the addition has happened. Aren't these features (tail recursion, strict, ...) among the reasons why Haskell got lazy strategies in the first place? And still, whenever time and storage do matter, we need to know how to control another, rather sophisticated machine. We still change our algorithms! I guess I'm repeating old commentary. > p2 :: [Int] -> Int -> Int > p2 xs m = sum . map head . takeWhile (not . null) . iterate (drop m) $ xs (Nitpick: This loops when m<=0, try "p2 [1] 0". (*)). While *Main> picksum [1 .. 123456789] 6 was done after some 28 seconds (19 seconds with your !a-ccumulator and pragma {-# LANGUAGE BangPatterns #-}, news to me, thanks!), I waited minutes after intense disk swapping for *Main> p2 [1 .. 123456789] 6 ^C Seems another feature of prototyping is apparent: can't use larger data sets. I guess I have also missed some way or other of controlling the prototyping interpreter (GHCi) that would make it produce more efficient code, ways that would be "obvious" to ... of course ;-) __ (*) The effect is somewhat like that of asking the Heart of Gold for tea. So, careful!