comp.lang.ada
 help / color / mirror / Atom feed
From: David Trudgett <wpower@zeta.org.au.nospamplease>
Subject: Re: Charles container library usage examples
Date: Sun, 04 Sep 2005 16:25:41 +1000
Date: 2005-09-04T16:25:41+10:00	[thread overview]
Message-ID: <m31x45jqmy.fsf@rr.trudgett> (raw)
In-Reply-To: m2wtlylc2i.fsf@grendel.local


Hi Simon,

Simon Wright <simon@pushface.org> writes:

> Matthew Heaney <matthewjheaney@earthlink.net> writes:
>
>> David Trudgett <wpower@zeta.org.au.nospamplease>  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




  reply	other threads:[~2005-09-04  6:25 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-03  2:38 Charles container library usage examples David Trudgett
2005-09-03  5:15 ` Matthew Heaney
2005-09-03  9:45   ` Simon Wright
2005-09-04  6:25     ` David Trudgett [this message]
2005-09-05 11:28       ` Georg Bauhaus
2005-09-04  0:26   ` David Trudgett
2005-09-04  9:49     ` Matthew Heaney
2005-09-06  3:01       ` David Trudgett
2005-09-06 16:22         ` Jeffrey Carter
2005-09-07  0:15         ` Matthew Heaney
2005-09-04 17:19     ` Ludovic Brenta
2005-09-06  3:01       ` David Trudgett
2005-09-06  5:08         ` Ludovic Brenta
2005-09-06  6:46           ` David Trudgett
2005-09-06  7:26             ` Ludovic Brenta
2005-09-24  0:05               ` Randy Brukardt
2005-09-09 14:57         ` James Alan Farrell
2005-09-10  7:38           ` David Trudgett
2005-09-10 14:55             ` Matthew Heaney
2005-09-10 15:26               ` Ludovic Brenta
2005-09-10 17:58                 ` Matthew Heaney
2005-09-12  0:24               ` Robert A Duff
2005-09-11 10:52             ` Georg Bauhaus
2005-09-11 21:14               ` David Trudgett
2005-09-13 23:41                 ` Björn Persson
2005-09-14  6:39                   ` David Trudgett
2005-09-12  0:21             ` Robert A Duff
2005-09-12  0:57               ` David Trudgett
2005-09-12  1:01                 ` Robert A Duff
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox