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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,9c9db81a63ddf1fe X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!postnews.google.com!dr5g2000vbb.googlegroups.com!not-for-mail From: Ludovic Brenta Newsgroups: comp.lang.ada Subject: Re: extended membership tests Date: Thu, 31 Mar 2011 01:05:49 -0700 (PDT) Organization: http://groups.google.com Message-ID: <067fc2c3-fef5-4da4-9582-3a7d3df7b3a7@dr5g2000vbb.googlegroups.com> References: <7dc23d58-4a48-4444-90cd-7f9786b19aad@i14g2000yqe.googlegroups.com> NNTP-Posting-Host: 153.98.68.197 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1301558749 2733 127.0.0.1 (31 Mar 2011 08:05:49 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 31 Mar 2011 08:05:49 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: dr5g2000vbb.googlegroups.com; posting-host=153.98.68.197; posting-account=pcLQNgkAAAD9TrXkhkIgiY6-MDtJjIlC User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.0.6) Gecko/2009012111 Red Hat/3.0.6-1.el5 Firefox/3.0.6,gzip(gfe) Xref: g2news2.google.com comp.lang.ada:19593 Date: 2011-03-31T01:05:49-07:00 List-Id: Dan wrote: > Here's a fun quiz to test your Ada2012 knowledge, based on an > observation by Yannick Moy. > > Consider this Ada 2012 procedure: > > with ada.containers.ordered_sets; > procedure membership is > =A0 =A0 package int_sets is new ada.containers.ordered_sets(integer); > =A0 =A0 function "=3D"(x,y: integer) return boolean is begin return true; > end; > =A0 =A0 x: integer :=3D 6; > =A0 =A0 y: integer :=3D 12; > =A0 =A0 b1: boolean :=3D x in y; > =A0 =A0 b2: boolean :=3D x in int_sets.to_set(new_item =3D> y); > begin > =A0 =A0 null; > end; > > Which of the following are true: > =A0 a) =A0b1 is true because 6 <=3D 12; > =A0 b) =A0b1 is true because abs(6) <=3D abs(12); > =A0 c) =A0b1 is true because 12 is an integer multiple of 6; > =A0 d) =A0b1 is true because the binary representation of 6 appears in th= e > binary representation of 12; > =A0 e) =A0b1 is true because x=3Dy is true (using redefined "=3D"); > =A0 f) =A0 b1 is false because x=3Dy is false (using standard."=3D"); > =A0 g) =A0b2 is false because 6 is not in the set containing only the > number 12; > =A0 h) =A0the program is illegal because of b1; > =A0 i) =A0 the program is illegal because of b2. Nice quiz... I'll post my answers later, to allow others to think some more about it... or maybe all interested people should reply to you privately? would you publish the results later? :) -- Ludovic Brenta.