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 X-Google-Thread: a07f3367d7,d00514eb0749375b,start X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!feeder.erje.net!news2.arglkargh.de!news.mixmin.net!aioe.org!not-for-mail From: "Nasser M. Abbasi" Newsgroups: comp.lang.ada Subject: initialize an array (1-D) at elaboration using an expression based on the index? Date: Fri, 15 Oct 2010 16:03:52 -0700 Organization: Aioe.org NNTP Server Message-ID: Reply-To: nma@12000.org NNTP-Posting-Host: tUYQ4Ty9mMw9Pdc8TJRFQA.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org X-Notice: Filtered by postfilter v. 0.8.2 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.9) Gecko/20100915 Thunderbird/3.1.4 Xref: g2news2.google.com comp.lang.ada:15522 Date: 2010-10-15T16:03:52-07:00 List-Id: Ada experts: I am not able to find an example on this. I was wondering if in Ada I can initialize some array, where I can fill the content of each entry in the array based on some function of the index? For example, in Fortran one can do this: ----------------------- program main integer, parameter :: N = 10 real, dimension(N) :: a=(/(j**2,j=1,N)/) print*, a end program ------------------------ $ gfortran t3.f90 $ ./a.exe 1.0000000 4.0000000 9.0000000 16.000000 etc.... In Ada, what would I need to do in the initialization below? --------------------------- procedure t2 is N: constant integer := 10; a: array(1..N) of float := (others=>0.0); --?? begin null; end t2; ----------------------------- I know ofcourse I can initialize it in the body by a loop, just wanted to see if it is possible to do it in the elaboration. thanks --Nasser