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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,35edde140291c79e X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.197.193 with SMTP id iw1mr7080949pbc.0.1335473657420; Thu, 26 Apr 2012 13:54:17 -0700 (PDT) Path: r9ni101893pbh.0!nntp.google.com!news2.google.com!volia.net!news2.volia.net!feed-A.news.volia.net!news.musoftware.de!wum.musoftware.de!news.swapon.de!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: Okasu Newsgroups: comp.lang.ada Subject: Re: Can Ada iterate over Nd array? Date: Thu, 26 Apr 2012 20:54:16 +0000 (UTC) Organization: A noiseless patient Spider Message-ID: References: <393172.2032.1335455290715.JavaMail.geo-discussion-forums@yntt13> Mime-Version: 1.0 Injection-Date: Thu, 26 Apr 2012 20:54:16 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="aw+qZcSY9gYG772+yj0T6Q"; logging-data="3847"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18BsVEQsRNy608OJznEnwkA" User-Agent: slrn/0.9.9p1 (Linux) Cancel-Lock: sha1:nfWlR5uGqPBOy29l9QqWd8YCGHo= Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: 2012-04-26T20:54:16+00:00 List-Id: On 2012-04-26, Adam Beneschan wrote: > On Wednesday, April 25, 2012 11:02:13 PM UTC-7, Okasu wrote: >> On 2012-04-26, Jeffrey Carter wrote: >> > >> > type Three_D is array (1 .. 3, 7 .. 300, 'A' .. 'Z') of Integer; >> > >> > A : Three_D; >> > >> > for I in A'range (1) loop >> > for J in A'range (2) loop >> > for K in A'range (3) loop >> > -- Do something with A (I, J, K) >> > end loop; >> > end loop; >> > end loop; >> > >> >> It's a brain dead code. >> So you trying to say that i have to write loops for 10/100/1000d arrays >> by hand? > > I don't think I've *ever* seen an array with more than three dimensions ever used, in 35 years of programming. (Exception: I think I once created a 4-dimensional array in APL in an attempt to write a one-line function to do something complicated. But that's more of a game, not really programming.) If you really need a way to associate arbitrarily long tuples with elements, you probably should be using some other kind of structure than an array. > > But I think Ada 2012 does support what you're looking for; see the example at the bottom of 5.5.2 (http://www.ada-auth.org/standards/12rm/html/RM-5-5-2.html). > > -- Adam Thanks, it's exactly what i'm looking for, i'm happy to know that i can easily iterate over any kind of array in Ada.