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: 103376,db88d0444fafe8eb X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!news.glorb.com!solnet.ch!solnet.ch!newsfeed.freenet.de!newsfeed.arcor.de!news.arcor.de!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Surprise in array concatenation Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.14.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <1125544603.561847.32140@g47g2000cwa.googlegroups.com> <14muavojz308w.1ouv7xin79rqu$.dlg@40tude.net> <4318486f$0$24154$9b4e6d93@newsread4.arcor-online.net> <43187a50$0$24162$9b4e6d93@newsread4.arcor-online.net> <11p5i525v2q5d$.17ayuwvqhazo1.dlg@40tude.net> <431a00cb$0$2113$9b4e6d93@newsread2.arcor-online.net> <9s72daxfzb4f.1k7noh1qr5qpg.dlg@40tude.net> <431c465d$0$24150$9b4e6d93@newsread4.arcor-online.net> <79fcfodixv3k$.1m7d28joczncs$.dlg@40tude.net> <431c8c35$0$2101$9b4e6d93@newsread2.arcor-online.net> <3ufj318nkubi.a5j4dbvaofhc.dlg@40tude.net> <431d82e3$0$24147$9b4e6d93@newsread4.arcor-online.net> <431dbabc$0$24153$9b4e6d93@newsread4.arcor-online.net> <1b8825x3b8wn3.24qm946raz3d$.dlg@40tude.net> <431f2f4f$0$2102$9b4e6d93@newsread2.arcor-online.net> Date: Wed, 7 Sep 2005 23:23:56 +0200 Message-ID: <3sa7ilukre24.15c984skqvm9c$.dlg@40tude.net> NNTP-Posting-Date: 07 Sep 2005 23:23:14 MEST NNTP-Posting-Host: dd50f2ac.newsread2.arcor-online.net X-Trace: DXC=RM<<>IO7D5Q\6[GEd:nl>[Q5U85hF6f;TjW\KbG]kaMXQ>n?D9BSA]\@WLLO>ILfT_WRXZ37ga[7Zeh9Z=IkP^1T>\7d=ooXaM\ X-Complaints-To: abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:4510 Date: 2005-09-07T23:23:14+02:00 List-Id: On Wed, 07 Sep 2005 20:20:56 +0200, Georg Bauhaus wrote: > Dmitry A. Kazakov wrote: >> On Tue, 06 Sep 2005 17:51:11 +0200, Georg Bauhaus wrote: > > Almost no real number can be represented in a computer. OK, it is beaten to death. See Richard's paradox. Its free interpretation, I quote J. E. Littlewood from memory, is: let there be integer numbers which cannot be defined by sentences shorter than 12 words. "This set is bounded and thus contains the lowest number N." This sentence defines N and amazingly contains only 11 words. >>>>Do you really believe >>>>that 1 is *the* 1? Did you see a label "made in Heaven" on it? (:-)) >>> >>>Type Positive starts at 1 and ends with Positive'Last. > >> ... and it does this not symbolically, but physically > > yes. > >> by attaching a tiny >> rubber thread to the Platonic number 1. Right? (:-)) > > no. How else you could check if 1 really refers to the physical 1! Maybe some scoundrel has reconnected all 1s in your computer to the physical 946.23, while you slept! (:-)) >> You are trying to formulate some generic algorithm which does not work for >> all index types. > > My algorithm should work for arrays, using properties of arrays. > A'First .. A'Last, where A'First > A'Last works well in loops. > > When are you interested in computing the value half-way between > the ends of a (non-numeric) enumeration type, attempting to use > A'Length / 2? Iteration algorithms in numeric analysis. Of course Length/2 is nonsense, but (Xn+Xm)/2 or Xn+(Xm-Xn)/2 or its generalization G*(Xn+Xm) is used quite often. For example, Xi can be from a vector space. G can be a matrix which norm is 0.5. >> This is why it is so important to have a consistent model >> of indexing and arrays. > > It is important to be consistently using the proper type of arrays > in algorithms made for this type of arrays. > >> For an unordered [index] type X it is wrong to >> assume that: > > Can there be an index type in Ada that isn't ordered? Sure: type Unordered_Index is (A, B, C, D); function "<" (Left, Right : Unordered_Index) return Boolean is abstract; type Unordered_Array is array (Unordered_Index) of Integer; >> 1. If L in X and U in X then there is always M in X between L and U >> 2. That M can be computed as (L+U)/2 > > You can't usually compute M when X is an enumeration type. > Otherwise, if A'Length <= 1, then (L+U)/2 = 0 = M. > Thus, M can be computed but is not necessarily between L and U. 1. This is plain wrong. If L=U then (L+U)/2=L. In general, it is always so that min(L,U) <= (L+U)/2 <= max(L,U), when ordered numbers are considered. (For generalizations on unordered cases see "convex hull") 2. M could not be computed just because "+", "/", 2 aren't defined. Then of course there could be no order; 3. Note that (1) is wrong for modular types. Not surprisingly, they aren't numbers, but classes of equivalence (sets of numbers, infinite sets, BTW, yet representable in the computer, how strange (:-)). As such they don't posses the order of numbers. See "rings of congruence classes." Alas but, here (modular types) Ada is again not very inconsistent. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de