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: Wed, 6 Sep 2023 17:54:47 +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> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Wed, 6 Sep 2023 15:54:47 -0000 (UTC) Injection-Info: dont-email.me; posting-host="45219ce80d83fc0bae96dda1999b3d4d"; logging-data="2701186"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19kUA6Kfvz/kG7GRHACoOzECaWnsC3R2yY=" User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.15.0 Cancel-Lock: sha1:3gOuW/gfwh7m6Bk12OM7ow994kM= In-Reply-To: <87jzt3qqlb.fsf@bsb.me.uk> Content-Language: en-US Xref: news.eternal-september.org comp.lang.ada:65606 List-Id: On 2023-09-06 17:16, Ben Bacarisse wrote: > I am curious to know how reusable this is. Can the packages be > instantiated in such a way that the argument ranges over the elements > of, say, and Ordered_Map? Sure: with Ada.Containers.Ordered_Maps; package Integer_Maps is new Ada.Containers.Ordered_Maps (Integer, Integer); use Integer_Maps; package Cursor_Arguments is new Generic_Arguments (Cursor); package Map_Values is new Generic_Values (Integer); package Map_Functions is new Generic_Discrete_Comparable_Valued (Cursor_Arguments, Map_Values); Then given X is a map: X : Map; Map_Functions.Maximum_At (X.First, X.Last, Element'Access) > Maybe a more generic a solution would involve passing something that can > be iterated over, rather than two values of an "enumerated" type? I > mean enumerated in the mathematical sense -- it may be the wrong word in > Ada. Yes, but Ada does not have built-in range types. Therefore such design will not work out of the box with discrete types because 2..999 is not a proper object in Ada. However, talking about abstractions, you can create an interval type for the purpose or else use an ordered set of integers. > I am asking you but I am also the group. I appreciate your help, > but don't want you to feel any obligation to keep helping! No problem. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de