From: Shark8 <onewingedshark@gmail.com>
Cc: nma@12000.org
Subject: Re: how to print an array range?
Date: Wed, 27 Jun 2012 23:59:39 -0700 (PDT)
Date: 2012-06-27T23:59:39-07:00 [thread overview]
Message-ID: <ee441a64-7029-439d-aa7b-8c6f22d299f7@googlegroups.com> (raw)
In-Reply-To: <jscegj$eoh$1@speranza.aioe.org>
On Tuesday, June 26, 2012 8:47:01 AM UTC-5, Nasser M. Abbasi wrote:
> simple question from newbie. How do I print array range?
> I tried using image' attribute, but can't get the syntax to
> work right.
>
> ----------------------------
> with Ada.Text_Io; use Ada.Text_Io;
> with Ada.Float_Text_Io; use Ada.Float_Text_Io;
> with Ada.integer_Text_Io; use Ada.integer_Text_Io;
> with Ada.Numerics.Real_Arrays; use Ada.Numerics.Real_Arrays;
>
> procedure foo1 is
> A : constant Real_Matrix :=
> (( 1.0, 2.0, 3.0),
> ( 4.0, 5.0, 6.0),
> ( 7.0, 8.0, 9.0));
> begin
>
> put(A'range(1));
>
> end foo1;
> ----------------------
>
> I expected to see "1..3". How do you use image' on this
> or other way to display the range?
>
> thanks,
> --Nasser
Ok, let's say you have Array_Type which is defined as Array (Integer Range <>) of Integer. We can achieve this by the following function:
Procedure Put_Range( A : In Array_Type ) is
Use Text_IO, Integer_IO;
begin
Put( A'First );
Put( ".." );
Put( A'Last );
end Put_Range;
For a mulch-dimensional array you would do something similar either a) calling the given function as an iteration through the minor-index, or b) expanding the above with the 'Range(Index_Number) attribute. {If I remember the attribute name correctly.}
prev parent reply other threads:[~2012-06-28 7:01 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-26 13:47 how to print an array range? Nasser M. Abbasi
2012-06-26 13:54 ` Georg Bauhaus
2012-06-26 14:08 ` Nasser M. Abbasi
2012-06-26 14:24 ` Nasser M. Abbasi
2012-06-26 15:07 ` AdaMagica
2012-06-26 15:53 ` Georg Bauhaus
2012-06-26 16:28 ` Nasser M. Abbasi
2012-06-26 16:58 ` Georg Bauhaus
2012-06-26 17:05 ` John B. Matthews
2012-06-26 17:13 ` Georg Bauhaus
2012-06-26 19:28 ` John B. Matthews
2012-06-26 17:15 ` Adam Beneschan
2012-06-26 21:31 ` Robert A Duff
2012-06-26 22:17 ` Dmitry A. Kazakov
2012-06-26 22:39 ` Randy Brukardt
[not found] ` <33dku79r14uuvmlgpodg9ri7prnq9v5f94@invalid.netcom.com>
2012-06-26 23:13 ` Jeffrey Carter
2012-06-27 6:58 ` Jacob Sparre Andersen
2012-06-26 14:07 ` Dmitry A. Kazakov
2012-06-28 6:59 ` Shark8 [this message]
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox