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=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,80435549e92d4e0c X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!news.glorb.com!nx01.iad01.newshosting.com!newshosting.com!elnk-atl-nf1!newsfeed.earthlink.net!stamper.news.atl.earthlink.net!newsread3.news.atl.earthlink.net.POSTED!14bb18d8!not-for-mail Sender: mheaney@MHEANEYX200 Newsgroups: comp.lang.ada Subject: Re: Charles container library usage examples References: From: Matthew Heaney Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Sat, 03 Sep 2005 05:15:45 GMT NNTP-Posting-Host: 24.149.57.125 X-Complaints-To: abuse@earthlink.net X-Trace: newsread3.news.atl.earthlink.net 1125724545 24.149.57.125 (Fri, 02 Sep 2005 22:15:45 PDT) NNTP-Posting-Date: Fri, 02 Sep 2005 22:15:45 PDT Organization: EarthLink Inc. -- http://www.EarthLink.net Xref: g2news1.google.com comp.lang.ada:4416 Date: 2005-09-03T05:15:45+00:00 List-Id: David Trudgett writes: > Does anyone know where I can find some usage examples for the Charles > container library, or some code that makes use of Charles? Here's my Ada-Europe 2004 tutorial: http://charles.tigris.org/charles_tutorial.ppt http://charles.tigris.org/charles_tutorial.pdf My original AI-302 proposal was based on Charles, and contains many examples: http://home.earthlink.net/~matthewjheaney/charles/ai302.txt > I've got Charles downloaded and installed on my include path, but as a > newcomer to Ada, I'm having difficulty working out how it is intended > to be used. Charles is more or less a port of the STL to Ada95, so if you can follow an STL tutorial (there are lots of them on the web), then you shouldn't have any problem extrapolating that to Charles. The standard container library has changed significantly from my original proposal, but even so you should be able to follow the AI-302 examples: http://charles.tigris.org/source/browse/charles/src/ai302/examples/ > The first thing I had in mind to do was to create a simple map, for > example, to translate the following Common Lisp: > > (defvar *side-corners* > '((2 (1 3)) > (4 (1 7)) > (6 (3 9)) > (8 (7 9)))) You can use a map, instantiated with type Integer as the key and an instantiation of a list as the element. Either the hashed map or the ordered map would suffice. > This is just a simple mapping of four particular integers (2, 4, 6, 8) > to four particular lists each consisting of two integers. > > I use it in a function like this: > > (defun side-corners (side) > "Return a list of the (two) corners that flank the given side" > (second (assoc side *side-corners*))) > > so that the function call > > (side-corners 2) > > returns the list (1 3) Something like (I have omitted a few steps): procedure Op (Map : Container_Type) is I : constant Iterator_Type := Find (Map, Key => 2); L : List_Types.Container_Type renames To_Access (I).all; begin ... end; This is similar to the C++ code: void f(const map_t& m) { const map_t::const_iterator i = m.find (2); const list_t& L = *i; //... } > Any pointers to code samples, or other hints would be greatly > appreciated! Send me email (or continue posting to CLA) if you need any help. -Matt