comp.lang.ada
 help / color / mirror / Atom feed
From: Pascal Obry <pascal@obry.net>
Subject: Re: Array index overloading
Date: Wed, 06 Aug 2014 18:53:29 +0200
Date: 2014-08-06T18:53:29+02:00	[thread overview]
Message-ID: <1407344009.27487.17.camel@pascal.home.net> (raw)
In-Reply-To: 03d102e1-1c2f-4056-82d5-3eaaaffbb0f1@googlegroups.com

Le mercredi 06 août 2014 à 09:47 -0700, marmaduke.woodman@univ-amu.fr a
écrit : 
> I am new to Ada and have perhaps a boring question, coming from array oriented languages such as MATLAB & NumPy in Python: 
> 
> Is it possible to overload the indexing operator? For example, in the aforementioned languages, one could index with the value 1 to get the first element, or index with a vector [2, 3, 4] to obtain a vector of the 2nd, 3rd and 4th elements. 

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.

-- 
  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


  reply	other threads:[~2014-08-06 16:53 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-06 16:47 Array index overloading marmaduke.woodman
2014-08-06 16:53 ` Pascal Obry [this message]
2014-08-06 17:38   ` marmaduke.woodman
2014-08-06 19:25     ` Georg Bauhaus
2014-08-06 19:43     ` Adam Beneschan
2014-08-06 21:51     ` Pascal Obry
2014-08-06 23:53     ` Shark8
2014-08-06 17:36 ` Peter Chapin
2014-08-07  5:17   ` Randy Brukardt
replies disabled

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