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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,8fbfbe3b40093d7d X-Google-Attributes: gid103376,public From: mfb@mbunix.mitre.org (Michael F Brenner) Subject: Re: comparing data Date: 1997/10/03 Message-ID: <613ccc$6vn@top.mitre.org>#1/1 X-Deja-AN: 277848238 References: Organization: The MITRE Corporation Newsgroups: comp.lang.ada Date: 1997-10-03T00:00:00+00:00 List-Id: Well, maybe it can be done in one IF statement, but here is a solution that takes a few IF statements. Assuming that these three values are in a random access container, one way to approach the problem of displaying the lowest value is as follow. type indexes is range 1..3; type values is range 1 .. 1_000_000; package education is new links_on_a_chain (values, indexes); education.rtm(5); -- The first one is on the linked list education.rtm(1); -- The second value is on the linked list education.rtm(9284); -- The Third value is on the linked list -- The three values are in the container called education. if education.remember (1) >= education.remember(2) and education.remember (1) >= education.remember(3) then education.delete_fact (1); -- One is the biggest end if; if education.remember (2) >= education.remember(1) and education.remember (2) >= education.remember(3) then education.delete_fact (2); -- Two is the biggest end if; if education.remember (3) >= education.remember(1) and education.remember (3) >= education.remember(2) then education.delete_fact (3); -- Three is the biggest end if; -- At this point, the largest, and possibly the second -- largest element in the container has been deleted. if education.number_of_elements = 1 then text_io.put_line (values'image (education.arb)); raise success; end if; education.effect_a_reorganization; -- At this point, there are two elements in the -- container, whose indexes are 1 and 2. if education.remember (1) >= education.remember (2) then education.delete_fact (1); else education.delete_fact (2); end if; education.effect_a_reorganization; -- At this point, there is one element of the list. text_io.put (values'image (education.remember (1))); text_io.put_line ("is the smallest value");