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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: Pascal Obry Newsgroups: comp.lang.ada Subject: Re: Array index overloading Date: Wed, 06 Aug 2014 18:53:29 +0200 Organization: Home - http://www.obry.net Message-ID: <1407344009.27487.17.camel@pascal.home.net> References: <03d102e1-1c2f-4056-82d5-3eaaaffbb0f1@googlegroups.com> Reply-To: pascal@obry.net NNTP-Posting-Host: wmuc4KI58jC360alAp9h9Q.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Complaints-To: abuse@aioe.org X-Mailer: Evolution 3.12.2-1+b1 X-Notice: Filtered by postfilter v. 0.8.2 Xref: news.eternal-september.org comp.lang.ada:21491 Date: 2014-08-06T18:53:29+02:00 List-Id: Le mercredi 06 ao=C3=BBt 2014 =C3=A0 09:47 -0700, marmaduke.woodman@univ-am= u.fr a =C3=A9crit :=20 > I am new to Ada and have perhaps a boring question, coming from array ori= ented languages such as MATLAB & NumPy in Python:=20 >=20 > Is it possible to overload the indexing operator? For example, in the afo= rementioned languages, one could index with the value 1 to get the first el= ement, or index with a vector [2, 3, 4] to obtain a vector of the 2nd, 3rd = and 4th elements.=20 If I understand correctly what you want, it is built-in in Ada: type Arr is array (positive range <>) of Natural; V : Arr (1 .. 78); Then V (1) is the first element (a Natural) V (2 .. 4) is an array of 3 naturals with first index being 2 and last 4. --=20 Pascal Obry / Magny Les Hameaux (78) The best way to travel is by means of imagination http://v2p.fr.eu.org http://www.obry.net gpg --keyserver keys.gnupg.net --recv-key F949BD3B