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: Fri, 08 Sep 2023 22:02:36 +0100 Organization: A noiseless patient Spider Message-ID: <87tts4ml8z.fsf@bsb.me.uk> 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> MIME-Version: 1.0 Content-Type: text/plain Injection-Info: dont-email.me; posting-host="b39237310d6b9749d50605be679823cd"; logging-data="3894748"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18z8KG8Jur2whZJXuj19m/V18Vz7Qjmknk=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) Cancel-Lock: sha1:R9BKgnKwPMGUGntiSJybTkOw4pA= sha1:e/JS1d9bVkeLrO7ulDXR3a+NvT8= X-BSB-Auth: 1.808533b7bfad398745e4.20230908220236BST.87tts4ml8z.fsf@bsb.me.uk Xref: news.eternal-september.org comp.lang.ada:65621 List-Id: "G.B." writes: > On 07.09.23 01:32, Ben Bacarisse wrote: > > >> A fix (though it's not really ideal) would be to use function >> composition here (inventing . as the composition operator): > > Hm. A stateful, composed function that needs to be applied > in a certain way. Is that so different from calling interface > subprograms of a certain type? There was nothing stateful (as I understand the term) in either function being composed. As to your question, not being an Ada expert I can't answer. I could not see any fix other than passing a composed function which would, it seems, have to be written afresh. Is that what your question refers to? If so, then yes there is a small difference: writing a function (albeit just a few lines) vs. applying an operator to two already written functions. > A wild guess: only "monads" would add substantial toppings > to the commonalities. Considering the computational powers of > C++'s "hair-raising template metaprogramming" [14.4], the idea > of "Ada generics" = "functional style" is probably limited > in scope. > > So, does type composition help? My turn to guess now: you are not being serious? I see no connection to monads or type composition. And why bring C++ into it? Having found the maximum of the function 'Period' over a range 2..999, you might find yourself a week later wanting the maximum absolute value of the numbers in an Ordered_Map. And then later the maximum of sine squared over the elements of 2D array. You might want to have a resuable "maximum of F over X" function, so I was curious about how close one could get to this in Ada (or, more accurately, what the restrictions on X and F might have to be). -- Ben.