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: Sun, 10 Sep 2023 10:46:04 +0200 Organization: A noiseless patient Spider Message-ID: References: <878r9mudvj.fsf@bsb.me.uk> <87a5u1u1yv.fsf@bsb.me.uk> <8734ztttpc.fsf@bsb.me.uk> <87fs3ssl6v.fsf@bsb.me.uk> <87a5u0rts0.fsf@bsb.me.uk> <87jzt3qqlb.fsf@bsb.me.uk> <87o7ieq3ne.fsf@bsb.me.uk> <8734zpo3fz.fsf@bsb.me.uk> <87a5twmbum.fsf@bsb.me.uk> <87tts2kenf.fsf@bsb.me.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sun, 10 Sep 2023 08:46:04 -0000 (UTC) Injection-Info: dont-email.me; posting-host="5879ac69b2dc570a842c2fc93c7d4b0d"; logging-data="556070"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/GAeYX1/ftImT9GNZFVfYxIbnN8jD+axU=" User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.15.0 Cancel-Lock: sha1:O0ijgHaJwJaLvTLn+JpIzSXk0j8= Content-Language: en-US In-Reply-To: <87tts2kenf.fsf@bsb.me.uk> Xref: news.eternal-september.org comp.lang.ada:65635 List-Id: On 2023-09-10 03:20, Ben Bacarisse wrote: > "Dmitry A. Kazakov" writes: > >> On 2023-09-09 02:25, Ben Bacarisse wrote: >>> "Dmitry A. Kazakov" writes: > >>>> [rant on] >>>> An Ada programmer would just write a loop. >>> Yes, that's fine. Different languages have different objectives. Just >>> write the empty range test and the loop you need for each kind of >>> collection. >> >> You can loop in Ada over empty ranges, no problem. > > Yes, but the problem in hand (maximum of F over X) should raise an error > on an empty X. I know there are other options, but you chose to > raise an error so that's the design I was talking about. It can be done by a Boolean flag. >>> That was definitely the way things were done in the 80s. >> >> Yes, before the Dark Ages of Computing... > > Eh? There have been repeated updates to the Ada language. Are they > taking Ada into the dark ages? If so, what was the golden age of Ada > when its design was perfect for numerical algorithms? I meant the state of computing as a whole. (Ada is a niche language and "hordes of barbarians" largely missed its existence... (:-)) >>>> As I said you think in a wrong direction of abstracting the language >>>> "finding maximum" rather than the problem space, e.g. generalization to >>>> other bases, other mathematical structures etc. >>> Generalising to an arbitrary base is local to the function that finds >>> the answer for one element. It's an entirely separate axis of >>> generalisation to that of where the elements come from. >>> It's interesting to me that you consider one simply wrong and the other >>> natural. >> >> Because one is a software design artifact and another is the result of >> problem space analysis. > > Which one the wrong one? None automatically is. The point is avoiding overdesigning a numeric puzzle. [...] > This is probably the closest we can get to a universal solution. > Vectors don't have a Key function but I am sure I could find out what > should be provided there. Vector has To_Index for Key. In general, note that Ada does not require you to use any library. I personally dislike cursors in particular because of their "functional" style. I prefer plain element position and loop iteration of ordered structures. A container library based on this paradigm would use other generic abstraction. Furthermore, I prefer dynamic polymorphism of tagged types over parametric one of generics. Therefore to me Maximum_At should rather be a class-wide or primitive operation than a generic. In Ada you have freedom to choose your way, which also massively reduces universality of any abstraction, which will never apply universally. I would like to have means to deal with this problem by means of ad-hoc supertypes, but that will never happen due to lack of interest in reworking the language type system and because in "Dark Ages" there is virtually no research on fundamental language construction topics. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de