From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED.8dY8omnix++EB5/QBRk4Sw.user.gioia.aioe.org!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: Tally Date: Tue, 14 Jan 2020 17:28:35 +0000 Organization: Aioe.org NNTP Server Message-ID: References: <3c6f1486-293d-4eb5-a379-279b108248d8@googlegroups.com> NNTP-Posting-Host: 8dY8omnix++EB5/QBRk4Sw.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain X-Complaints-To: abuse@aioe.org User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (darwin) Cancel-Lock: sha1:m1Vx+cx/1kU4N8h17pTlUgSytPo= X-Notice: Filtered by postfilter v. 0.9.2 Xref: reader01.eternal-september.org comp.lang.ada:57840 Date: 2020-01-14T17:28:35+00:00 List-Id: Niklas Holsti 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)