From: Simon Wright <simon@pushface.org>
Subject: Re: Tally
Date: Thu, 16 Jan 2020 11:34:55 +0000
Date: 2020-01-16T11:34:55+00:00 [thread overview]
Message-ID: <lyftgfzlb4.fsf@pushface.org> (raw)
In-Reply-To: d097db6b-b30c-4cbd-8343-b18592d924bc@googlegroups.com
Jere <jhb.chat@gmail.com> writes:
> I might recommend using insert every iteration and seeing if
> it fails or succeeds. Since it gives a cursor regardless of
> success, you can use that get the element and avoid doing
> all the searches each time:
>
> for Number of Input loop
>
> -- Try to insert a new element. This will
> -- fail if the element already exists
> Counts.Insert
> (Key => Number,
> New_Item => 1,
> Position => Position,
> Inserted => Inserted);
>
> -- Since the element already exists, simply
> -- increment the count
> if not inserted then
> Counts(Position) := Counts(Position) + 1;
> end if;
>
> end loop;
Yes, I thought about that. More LoC/less clarity without the comments
are the only objections I can see (though fairly compelling for toy
examples!)
next prev parent reply other threads:[~2020-01-16 11:34 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 ` Simon Wright [this message]
2020-01-16 15:35 ` Tally Brad Moore
2020-01-16 20:20 ` Tally Randy Brukardt
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