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!newsfeed.stanford.edu!newsfeed.berkeley.edu!ucberkeley!newsfeed.pacific.net.au!nasal.pacific.net.au!not-for-mail Newsgroups: comp.lang.ada Subject: Re: Charles container library usage examples From: David Trudgett Organization: Very little? References: Message-ID: User-Agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.4 (gnu/linux) Cancel-Lock: sha1:6Ke29P6nCUkNeaILnyjHUFSHEAs= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Sun, 04 Sep 2005 16:25:41 +1000 NNTP-Posting-Host: 61.8.38.134 X-Complaints-To: news@pacific.net.au X-Trace: nasal.pacific.net.au 1125815411 61.8.38.134 (Sun, 04 Sep 2005 16:30:11 EST) NNTP-Posting-Date: Sun, 04 Sep 2005 16:30:11 EST Xref: g2news1.google.com comp.lang.ada:4425 Date: 2005-09-04T16:25:41+10:00 List-Id: Hi Simon, Simon Wright writes: > Matthew Heaney writes: > >> David Trudgett writes: > >>> 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. > > I would have used (for example) > > type Axis is (X, Y); > type Coordinate is range 1 .. 8; > type Position is array (Axis) of Coordinate; > > as the element type (making some assumptions about the problem!). They do look like coordinates, don't they? :-) Does the following shed any light? procedure Print_Board_Key is begin New_Line; Put("The board squares are numbered as follows:"); New_Line(2); Put(" 1 | 2 | 3 "); New_Line; Put(" -----------"); New_Line; Put(" 4 | 5 | 6 "); New_Line; Put(" -----------"); New_Line; Put(" 7 | 8 | 9 "); New_Line(2); end Print_Board_Key; It's a simple tic tac toe game I'm playing around with to learn Ada. I'm planning to put a GUI onto it before I'm finished with it! > No need to have a list as the element if the problem doesn't call > for it (though good to be able to if needed, of course). It's a learning exercise, so doing things the hard way is not a problem! :-) I'm just a bit surprised that adding a map and a list to a program is turning into a major undertaking. I'm sure I'll get there, though. I might have to do some more study on generics, though I was hoping to be able to just *use* a map without having to have detailed knowledge of how generics work. Cheers, David -- David Trudgett http://www.zeta.org.au/~wpower/ No great cause is ever won or lost. The battle must always be renewed and the creed restated... For some things are universal, catholic and undying... These do not age or pass out of fashion, for they symbolize eternal things. They are the guardians of the freedom of the human spirit, the proof of what our mortal frailty can achieve. -- John Buchan, biographer of Montrose