comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Tally
Date: Thu, 16 Jan 2020 14:20:13 -0600
Date: 2020-01-16T14:20:13-06:00	[thread overview]
Message-ID: <qvqght$v9r$1@franka.jacob-sparre.dk> (raw)
In-Reply-To: 4967a95b-3d79-4a5b-a30d-0f04f00ebbc4@googlegroups.com

"Brad Moore" <bmoore.ada@gmail.com> wrote in message 
news:4967a95b-3d79-4a5b-a30d-0f04f00ebbc4@googlegroups.com...
...
> For that matter, you could do it all in one shot and even make the map a 
> constant.
>
>   Counts : constant Count_Maps.Map
>     := [for I in Input'Range
>           when (for all J in Input'First .. I - 1 => Input (I) /= Input 
> (J))
>              use I =>
>                 [for K in Input'Range when Input (K) = Input (I)) => 1]
>                   'Reduce("+", 0)];
>
> Using a reduction expression to count the values.
> But this is definitely quite a mouthful.

So Ada 202x will allow us to catch up to C++ and many other "expressive" 
languages by allowing us to have "guess what this code does" contests!! :-)

Compared to Jere's loop, the above is impentrable. And it's hard to guess 
the performance of that (I'd have to expand the aggregate into its 
underlying operations to figure out whether it is more or less expensive 
than the simple loop would be).

                            Randy.


  reply	other threads:[~2020-01-16 20:20 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-14 15:27 Tally Gilbert Gosseyn
2020-01-14 16:22 ` Tally Niklas Holsti
2020-01-14 17:28   ` Tally Simon Wright
2020-01-15 11:52     ` Tally Simon Wright
2020-01-14 21:08 ` Tally Jeffrey R. Carter
2020-01-15  3:40   ` Tally Brad Moore
2020-01-15  9:03     ` Tally Simon Wright
2020-01-15 23:09       ` Tally Jere
2020-01-16 11:34         ` Tally Simon Wright
2020-01-16 15:35           ` Tally Brad Moore
2020-01-16 20:20             ` Randy Brukardt [this message]
2020-01-16 22:03               ` Tally Jeffrey R. Carter
2020-01-16 22:00             ` Tally Jeffrey R. Carter
2020-01-16 22:25               ` Tally Simon Wright
2020-01-17  2:51                 ` Tally Brad Moore
2020-01-17  3:08       ` Tally Brad Moore
replies disabled

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