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=2.0 required=5.0 tests=BAYES_00,FORGED_MUA_MOZILLA, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,32d9aa9d79729b31 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.190.104 with SMTP id gp8mr15514996pbc.4.1340685677828; Mon, 25 Jun 2012 21:41:17 -0700 (PDT) Path: l9ni20721pbj.0!nntp.google.com!news1.google.com!goblin1!goblin2!goblin.stu.neva.ru!aioe.org!.POSTED!not-for-mail From: "Nasser M. Abbasi" Newsgroups: comp.lang.ada Subject: Re: Any easy/build-in construct to extract submatrices from larger matrix? Date: Mon, 25 Jun 2012 23:41:15 -0500 Organization: Aioe.org NNTP Server Message-ID: References: <1xzo3825h9yt7$.45flobqwlel6.dlg@40tude.net> <4FE896B5.10405@obry.net> Reply-To: nma@12000.org NNTP-Posting-Host: KdJUrTuvv3Zv/s8pPxNluw.user.speranza.aioe.org Mime-Version: 1.0 X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:13.0) Gecko/20120614 Thunderbird/13.0.1 X-Notice: Filtered by postfilter v. 0.8.2 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Date: 2012-06-25T23:41:15-05:00 List-Id: On 6/25/2012 1:49 PM, stefan-lucks@see-the.signature wrote: > 2. Specify the precondition (optional): > > function Is_Diagonal (M: Matrix) return Boolean > with Pre => M'First(1) = M'First(2) and M'Last(1) = M'Last(2); > > 3. Implement the function: > > function Is_Diagonal (M: Matrix) return Boolean is > (for all I in M'Range(1) > => (for all J in M'Range(2) > => (if I /= J then M(I, J) = 0.0))); > > This is four lines -- but the last two or three lines could be squeezed > into a single one, if all what matters is the line count, disregarding > readability. That is a very nice solution. Thanks. I'll have to wait for gnat 2012 to try it. (I assume the pre above is checking for square matrix, ps. the new iterator looks nice). --Nasser