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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,aa7f494bf30adbc7 X-Google-Attributes: gid103376,public Path: g2news1.google.com!news2.google.com!fu-berlin.de!uni-berlin.de!not-for-mail From: "Nick Roberts" Newsgroups: comp.lang.ada Subject: Re: [newbie] simple(?) data structures Date: Thu, 24 Jun 2004 15:50:26 +0100 Message-ID: <2k081iF16pb3qU1@uni-berlin.de> References: <2j1e30Fsrg8vU1@uni-berlin.de> <1ec946d1.0406231609.11a051cb@posting.google.com> X-Trace: news.uni-berlin.de popHDsjeDfH8wmBqlyeImwOnWS/BGqfWB86+rKa4Oq5p13vE8= X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 Xref: g2news1.google.com comp.lang.ada:1855 Date: 2004-06-24T15:50:26+01:00 List-Id: "Matthew Heaney" wrote in message news:1ec946d1.0406231609.11a051cb@posting.google.com... > package Go_Boards is > > type Board_Type (Size : Positive) is private; > > type Stone_Type is (Empty, Black, White); > > function Stone (Board : Board_Type) return Stone_Type; > > --function Width (B : BT) return Positive; --same as B.Size? > > private > > type Data_Type is > array (Positive range <>, Positive range <>) of Stone_Type; > > type Board_Type (Size : Positive) is record > Data : Data_Type (1 .. Size, 1 .. Size); > end record; > > end Go_Boards; (I can't resist improving on this a tad ;-) package Nicks_Go is type Board_Size is range 7..19; -- or whatever type Coordinate is range 0..Board_Size'Last; type Go_Board (Size : Board_Size) is private; type Cell_Content is (Empty, Black, White); subtype Stone_Color is Cell_Content range Black..White; function Cell ( Board : Go_Board; Row, Col: Coordinate) return Cell_Content; procedure Set_Cell ( Board : in out Go_Board; Row, Col: in Coordinate; Cell: in Cell_Content); private type Matrix_Array is array ( Coordinate range <>, Coordinate range <>) of Cell_Content; type Go_Board_Type (Size : Board_Size) is record Matrix: Matrix_Array(1..Size, 1..Size); -- row, col -- probably a lot of other stuff too end record; end Nicks_Go; package body Nicks_Go is function Cell ( Board : Go_Board; Row, Col: Coordinate) return Cell_Content is begin return Board.Matrix(Row,Col); end; procedure Set_Cell ( Board : in out Go_Board; Row, Col: in Coordinate; Cell: in Cell_Content) is begin Board.Matrix(Row,Col) := Cell; end; end Nicks_Go; Just for fun! -- Nick Roberts