comp.lang.ada
 help / color / mirror / Atom feed
From: Ben Bacarisse <ben.usenet@bsb.me.uk>
Subject: Re: project euler 26
Date: Tue, 05 Sep 2023 16:18:16 +0100	[thread overview]
Message-ID: <87fs3ssl6v.fsf@bsb.me.uk> (raw)
In-Reply-To: ud6l23$1sq44$1@dont-email.me

"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> writes:

> On 2023-09-05 01:16, Ben Bacarisse wrote:
>
>> The term "abstraction" is usually taken to be more general than that so
>> as to include function (or procedural) abstraction.
>
> These are means of software decomposition rather than abstraction (of
> something).

That's not how the word is usually used.  Obviously I can't (and don't
want to) change your mind, but algorithms can be abstracted as well as
data.

I was hoping someone could how me how in for the example program I gave
since that's an area of Ada I am not familiar with (but I's sure it's
possible).

>> Ada is good at that, but the syntax is sufficiently cumbersome that I
>> think it discourages people from exploiting that part of the language.
>> Mind you, I am no Ada expert so maybe it's simpler to do than I think.
>
> If the program does not resemble electric transmission noise, some people
> call the language syntax cumbersome... (:-))

That's true.  But there are also constructs that are genuinely
cumbersome in some languages.  Anyway, to find out more, I was hoping
someone would show me what it looks like in Ada -- I outlined what I
wanted to do after the code I posted.

>> Here's my Ada solution:
>> with Ada.Text_IO; use Ada.Text_IO;
>> with Ada.Containers.Ordered_Maps; use Ada.Containers;
>> procedure Euler_26 is
>>     function Period(Divisor: Positive) return Positive is
>
> You cannot use a number here because the period may have leading
> zeros.

The function returns the decimal period of 1/Divisor.  I don't believe
there is a bug, but if you think you've found one, I'd like to know
about it.

Of course there can be leading zeros, but my algorithm ignores the
digits and determines the period using the "carry" instead.

>> I know it won't make this program shorter, but it would be interesting
>> to know how it might be done.
>
> The goal of engineering is not making programs shorter, it is to make them
> understandable, safer, reusable, maintainable, extensible, integrable.

Yes.  That's exactly why I was asking for someone who knows Ada better
to show me how to write the reusable component I described.  There was
boiler plate code in my program that could be abstracted out into a
generic function (or package?) so that any function can be maximised
over some range or, better yet, any iterable type (if that's how Ada
does things).

Can someone here show me how?

-- 
Ben.

  reply	other threads:[~2023-09-05 15:18 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-04  9:19 project euler 26 CSYH (QAQ)
2023-09-04 11:06 ` Niklas Holsti
2023-09-04 12:39   ` Dmitry A. Kazakov
2023-09-04 16:01     ` Ben Bacarisse
2023-09-04 19:20       ` Dmitry A. Kazakov
2023-09-04 20:18         ` Ben Bacarisse
2023-09-04 21:00           ` Dmitry A. Kazakov
2023-09-04 23:16             ` Ben Bacarisse
2023-09-05  7:23               ` Dmitry A. Kazakov
2023-09-05 15:18                 ` Ben Bacarisse [this message]
2023-09-05 17:08                   ` Dmitry A. Kazakov
2023-09-06  1:10                     ` Ben Bacarisse
2023-09-06  7:06                       ` Dmitry A. Kazakov
2023-09-06 15:16                         ` Ben Bacarisse
2023-09-06 15:54                           ` Dmitry A. Kazakov
2023-09-06 23:32                             ` Ben Bacarisse
2023-09-07  9:02                               ` Dmitry A. Kazakov
2023-09-08  1:32                                 ` Ben Bacarisse
2023-09-08  7:23                                   ` Dmitry A. Kazakov
2023-09-09  0:25                                     ` Ben Bacarisse
2023-09-09  9:32                                       ` Dmitry A. Kazakov
2023-09-10  1:20                                         ` Ben Bacarisse
2023-09-10  8:46                                           ` Dmitry A. Kazakov
2023-09-10 19:22                                             ` Ben Bacarisse
2023-09-11  6:53                                               ` Dmitry A. Kazakov
2023-09-11 16:13                                                 ` Ben Bacarisse
2023-09-12  7:17                                                   ` Dmitry A. Kazakov
2023-09-13 12:24                                                     ` Ben Bacarisse
2023-09-14  6:33                                                       ` Dmitry A. Kazakov
2023-09-14 14:30                                                         ` Ben Bacarisse
2023-09-08  6:09                               ` G.B.
2023-09-08 21:02                                 ` Ben Bacarisse
2023-09-09  8:13                                   ` G.B.
2023-09-09 21:04                                     ` Ben Bacarisse
2023-09-10  9:11                                     ` Dmitry A. Kazakov
2023-09-05 17:35                 ` moi
2023-09-04 14:23 ` Dmitry A. Kazakov
2023-09-07  7:31 ` Francesc Rocher
2023-09-15  9:07   ` CSYH (QAQ)
2023-09-19  7:59     ` comp.lang.ada
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox