From: Simon Wright <simon@pushface.org>
Subject: Re: Tally
Date: Tue, 14 Jan 2020 17:28:35 +0000
Date: 2020-01-14T17:28:35+00:00 [thread overview]
Message-ID: <lysgkiymkc.fsf@pushface.org> (raw)
In-Reply-To: h8686dF8hukU1@mid.individual.net
Niklas Holsti <niklas.holsti@tidorum.invalid> writes:
> On 2020-01-14 17:27, Gilbert Gosseyn wrote:
>> Before I make long tests with access Types, declarations or
>> containers, I would like to get an advice on how to program in a
>> simple and fast way the following, or get a hint to an existing
>> program.
>>
>> Example_Input: (2, 3, 8, 2, 2, 2, 7, 2, 3, 4, 8) ; -- variable Length
>>
>> Output by function or procedure : ((2, 5), (3, 2), (8, 2), (7, 1),
>> (4, 1)); -- unknown Length
>>
>> -- tallies the elements in Input, listing all distinct elements
>> together with their multiplicities
>>
>>
>> Thank you
>>
>
> Put the input numbers in a map container, keyed on the input number
> and giving the multiplicity so far of that number.
>
> When the input ends, output the map.
The Booch Components included Bags, which would solve this directly!
(not that I'd recommend anyone to use the BCs for a new project)
next prev parent reply other threads:[~2020-01-14 17:28 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 ` Simon Wright [this message]
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 ` 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