From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on ip-172-31-65-14.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-3.2 required=3.0 tests=BAYES_00,NICE_REPLY_A, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: project euler 26 Date: Mon, 4 Sep 2023 21:20:56 +0200 Organization: A noiseless patient Spider Message-ID: References: <878r9mudvj.fsf@bsb.me.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Mon, 4 Sep 2023 19:20:55 -0000 (UTC) Injection-Info: dont-email.me; posting-host="84abbd2dc2e4fea6082302e85e06124d"; logging-data="1692524"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/K1iz29hRQLbxtrwGPDdlVcCr+PqnEj2c=" User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.15.0 Cancel-Lock: sha1:G0MMDzEv/POWxittBTn5CDzcxlA= Content-Language: en-US In-Reply-To: <878r9mudvj.fsf@bsb.me.uk> Xref: news.eternal-september.org comp.lang.ada:65592 List-Id: On 2023-09-04 18:01, Ben Bacarisse wrote: > "Dmitry A. Kazakov" writes: > >> On 2023-09-04 13:06, Niklas Holsti wrote: >>> On 2023-09-04 12:19, CSYH (QAQ) wrote: >>>> I am new to Ada, I know is there a good way to start this program? >>>> thanks >>>> https://projecteuler.net/problem=26 >>> First invent/discover the method (algorithm) for solving the problem, >>> without thinking about the programming language. >>> I don't think any language has built-in features that would lead to a >>> direct solution, although some functional language with lazy evaluation >>> could come close, because such languages can manipulate unbounded >>> (potentially infinite) sequences of values. Such sequences can be handled >>> in Ada, too, but with more effort -- they are not "built in" to Ada. >> >> Infinite division does not require big numbers, which Ada 22 has, but I >> wound not use them anyway because the performance would be abysmal. >> >> BTW, Ada is perfect for numeric algorithms no need to resort to functional >> mess... (:-)) > > Perfect? That's a bold claim! Ada is a very improved descendant of Algol 60, which was designed to codify algorithms. > Mind you, I don't think this problem is really a numerical one in that > sense. It needs some simple integer arithmetic but then every language > is perfect for that sort of arithmetic. That is still all about algorithms (rather than about for example building abstractions as in the case of OOP) > Using a functional mess (Haskell) a simple, native solution (i.e. using > no modules) is only 9 lines long. Apart from the fundamental inconsistency of functional paradigm: computing is about transition of states and nothing else; the imperative languages express solutions, i.e. an algorithm. Functional, and in general, declarative languages express puzzles. They remind me a math examination tasks on studying a function. Here is a definition. Go figure out the properties and behavior... Or, if you want, functional is like a chess composition: white to move and checkmate in 4 moves. Challenging, but Ada is about playing chess. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de