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!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.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> <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> <3sa7ilukre24.15c984skqvm9c$.dlg@40tude.net> <432011f0$0$24147$9b4e6d93@newsread4.arcor-online.net> Date: Thu, 8 Sep 2005 15:44:52 +0200 Message-ID: <36f5y9ptjia3$.1onymsey119zw.dlg@40tude.net> NNTP-Posting-Date: 08 Sep 2005 15:44:53 MEST NNTP-Posting-Host: ddf72714.newsread4.arcor-online.net X-Trace: DXC=YCmAA8T_EUHO@oM:dhE>=@:ejgIfPPldDjW\KbG]kaMHea\9g\;7NmE4e4MoUjjd5E[6LHn;2LCVN7enW;^6ZC`D<=9bOTW=MNN X-Complaints-To: abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:4525 Date: 2005-09-08T15:44:53+02:00 List-Id: On Thu, 08 Sep 2005 12:27:50 +0200, Georg Bauhaus wrote: > Dmitry A. Kazakov wrote: > >> How else you could check if 1 really refers to the physical 1! > > Which physical 1? There is a written agreement on what represents > 1 inside a computer, per computer. Note that A=1 from the problem state is not a bit pattern. It is a set of computational states for which A is considered be 1. So when you make a memory dump and discover a bit pattern 000000001 at the address FF07712CA0 that tells absolutely nothing. > As I said, math declares the swamp > away into which it is built. Computer descriptions do soemthing similar. > I do not usually try to write programs using funny interpretations of > bits, and assume you don't either. I don't care about representations as long as they aren't the part of the problem space (like in communication protocols.) >>>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; > > I was thinking of index types that are not ordered in Ada. See > below. if A < B then -- Compile error! What else you need? >> 1. This is plain wrong. If L=U then (L+U)/2=L. > > As you say, "+" isn't predefined for enumeration types. > > As for M and (L+U)/2 I should have said, in Ada (and other PLs) > if 0 <= A'Length <= 1, then (L+U)/2 can be 0 = M, and A'Length/2 = 0, always. You cannot work with Length, it is another type! A'Length is universal integer see ARM 3.6.2. Mathematical equivalent of A'Length is distance between points A'First/A'Last. If you want to work with A'Length, then you have to switch from indices to the positions of, i.e. to I'Pos: Array : Index -> Element Index'Pos : Index -> Universal_Integer Note that working with positions breaks the abstraction, because the order of Index might be different from one of the position! If some day Ada will have abstract arrays, then "for I in A loop" should iterate it in the order of the Index, and not in the arbitrary one of Index'Pos. >> (For generalizations on unordered cases see "convex hull") > I'm trying to see arrays, and possible improvements. If a convex hull > offers something useful Believe me, convex sets (whether (1-t)a + tb belongs to the same set forall 0<=t<=1) are extremely important for countless numeric methods, computational geometry etc. >> 2. M could not be computed just because "+", "/", 2 aren't defined. Then of >> course there could be no order; > > But in fact, Ada's enumeration types are ordered. See above. > Try to make this pass Ada compilation, > > type Unordered_Index is (A, B, C, D); > for Unordered_Index use (A => 1, B => 3, C => 2, D => 4); This has little to do with the order of Unordered_Index. The representation clause defines representation. You should never mix: 1. The user-defined order and other operations (like +, -) and literals from the problem space; 2. The positions of discrete values; 3. The representations of discrete values. These all are different things. I hope it is clear that algorithms should be written in terms of (1)? >> 3. Note that (1) is wrong for modular types. > > And? and you could not write a generic array algorithm both relying on (1) and usable for modular types. >> Not surprisingly, they aren't >> numbers, > > That's news. There are numbers congruent modulo some number. > But you think these numbers aren't numbers? Yes. Modular 1 is an infinite set of numbers = { x | x = 1 (mod 16) }. You can try to abstract this fact by choosing some definite element from each of these sets. But you cannot do it completely. Because the structure is different from one of Z. Some important results valid for Z will not hold. What else would be the reason to have modular numbers? >> but classes of equivalence (sets of numbers, infinite sets, BTW, >> yet representable in the computer, how strange (:-)). > > One equivalence class is not the same as the set of numbers mapped > to members of the equivalence class. "type X is mod 10;" implies a > finite set of values. Try "a: X; a := 42;" In other words, 42 cannot > belong to the set of values expressed by X. You again mixing sets and elements of. 42 is a literal. In the case of equivalence classes it denotes not a number (Z) but a class of. There is no class X'(42) for mod 10. Yet 42, now as an element of Z, is one of X'(2) because 42=2(mod 10). > Belonging and congruence are not the same thing. They are exactly same. It is how the set is defined. > For example, we cannot count an absolute > number of items when there are at least as many items as the modulus. This is the same logic error as above with A'Length. The type of the cardinal numbers in Ada is defined as Universal_Integer. It is not the type of the elements in a set! (Taking too much C++ might be dangerous for your health! (:-)) -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de