comp.lang.ada
 help / color / mirror / Atom feed
* extended membership tests
@ 2011-03-31  7:04 Dan
  2011-03-31  7:34 ` AdaMagica
                   ` (3 more replies)
  0 siblings, 4 replies; 18+ messages in thread
From: Dan @ 2011-03-31  7:04 UTC (permalink / raw)


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
    package int_sets is new ada.containers.ordered_sets(integer);
    function "="(x,y: integer) return boolean is begin return true;
end;
    x: integer := 6;
    y: integer := 12;
    b1: boolean := x in y;
    b2: boolean := x in int_sets.to_set(new_item => y);
begin
    null;
end;

Which of the following are true:
  a)  b1 is true because 6 <= 12;
  b)  b1 is true because abs(6) <= abs(12);
  c)  b1 is true because 12 is an integer multiple of 6;
  d)  b1 is true because the binary representation of 6 appears in the
binary representation of 12;
  e)  b1 is true because x=y is true (using redefined "=");
  f)   b1 is false because x=y is false (using standard."=");
  g)  b2 is false because 6 is not in the set containing only the
number 12;
  h)  the program is illegal because of b1;
  i)   the program is illegal because of b2.



^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2011-04-02  1:22 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-31  7:04 extended membership tests Dan
2011-03-31  7:34 ` AdaMagica
2011-03-31  7:55   ` Dan
2011-03-31  7:58     ` Dan
2011-03-31  8:05 ` Ludovic Brenta
2011-03-31  9:28 ` AdaMagica
2011-03-31 14:33 ` Robert A Duff
2011-03-31 16:28   ` extended membership tests (branch) Georg Bauhaus
2011-03-31 17:58     ` Robert A Duff
2011-03-31 18:54     ` Adam Beneschan
2011-03-31 21:08       ` Georg Bauhaus
2011-03-31 21:10       ` Randy Brukardt
2011-04-01  5:14   ` extended membership tests AdaMagica
2011-04-01  6:33     ` Dan
2011-04-01  7:03       ` AdaMagica
2011-04-01  9:56         ` stefan-lucks
2011-04-01 15:11         ` Adam Beneschan
2011-04-02  1:22         ` Randy Brukardt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox