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=-1.9 required=3.0 tests=BAYES_00,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: Ben Bacarisse Newsgroups: comp.lang.ada Subject: Re: project euler 26 Date: Mon, 04 Sep 2023 21:18:16 +0100 Organization: A noiseless patient Spider Message-ID: <87a5u1u1yv.fsf@bsb.me.uk> References: <878r9mudvj.fsf@bsb.me.uk> MIME-Version: 1.0 Content-Type: text/plain Injection-Info: dont-email.me; posting-host="e2cb716c5442438ebe9264e332ee95d9"; logging-data="1710501"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Q1rY4WPB1sY6dAm5QKp6lIi6tlBJhRgU=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) Cancel-Lock: sha1:o1j/PPPMaWpJUZd2IjGdYBybSQs= sha1:GxMOXMrMWSDiQkr9d1fFyakBvjo= X-BSB-Auth: 1.8ca3d4d0d434a95267f5.20230904211816BST.87a5u1u1yv.fsf@bsb.me.uk Xref: news.eternal-september.org comp.lang.ada:65593 List-Id: "Dmitry A. Kazakov" writes: > 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. Yes, though I was respond to you narrower remark about being perfect for numeric algorithms. Are you expending that to perfect for every kind of algorithm? >> 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 Yes but, again, that's not what I was responding to. > (rather than about for example building > abstractions as in the case of OOP) That's interesting. You don't consider using functions and procedures (possibly higher-order ones) to be a way to build abstractions? >> 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. Rather than try to unpick that paragraph I'll just say that they can, none the less, give simple solutions to this sort of programming problem. -- Ben.