* comparing data
@ 1997-10-01 0:00 Big B
1997-10-02 0:00 ` Peter Hermann
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Big B @ 1997-10-01 0:00 UTC (permalink / raw)
ada experts,
I am just starting out in ada. could someone help me set up an if then
statement that will out put the lowest value of three pieces of data.
Please e-mail,
Thanks,
Brian
,,,,,,,,
.:::. .;'' '``;.
.... ::::: :: :: :: ::
,;' .;: () ..: `:::' :: :: :: ::
::. ..:,:;.,:;. . :: .::::. `:' :: .:' :: :: `:. ::
'''::, :: :: :: `:: :: ;: .:: : :: : : ::
,:'; ::; :: :: :: :: :: ::,::''. . :: `:. .:' ::
`:,,,,;;' ,;; ,;;, ;;, ,;;, ,;;, `:,,,,:' :;: `;..``::::''..;'
``::,,,,::''
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: comparing data
1997-10-01 0:00 comparing data Big B
1997-10-02 0:00 ` Peter Hermann
@ 1997-10-02 0:00 ` Tom Moran
1997-10-03 0:00 ` Michael F Brenner
2 siblings, 0 replies; 4+ messages in thread
From: Tom Moran @ 1997-10-02 0:00 UTC (permalink / raw)
if A <= B and A <= C then return A;
elsif B <= A and B <= C then return B;
else return C;
end if;
Not the most efficient, or the most easily generalized, but it works.
Now, why don't you make it more efficient by using nested 'if's or
something?
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: comparing data
1997-10-01 0:00 comparing data Big B
@ 1997-10-02 0:00 ` Peter Hermann
1997-10-02 0:00 ` Tom Moran
1997-10-03 0:00 ` Michael F Brenner
2 siblings, 0 replies; 4+ messages in thread
From: Peter Hermann @ 1997-10-02 0:00 UTC (permalink / raw)
Big B (hennib01@condor.stcloudstate.edu) wrote:
> ada experts,
^^^^^^^^^^^
are expected to do your homework ;-)
BTW: ^ this is a s m a l l smiley :-)
Peter Hermann Tel:+49-711-685-3611 Fax:3758 ph@csv.ica.uni-stuttgart.de
Pfaffenwaldring 27, 70569 Stuttgart Uni Computeranwendungen
Team Ada: "C'mon people let the world begin" (Paul McCartney)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: comparing data
1997-10-01 0:00 comparing data Big B
1997-10-02 0:00 ` Peter Hermann
1997-10-02 0:00 ` Tom Moran
@ 1997-10-03 0:00 ` Michael F Brenner
2 siblings, 0 replies; 4+ messages in thread
From: Michael F Brenner @ 1997-10-03 0:00 UTC (permalink / raw)
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");
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~1997-10-03 0:00 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-10-01 0:00 comparing data Big B
1997-10-02 0:00 ` Peter Hermann
1997-10-02 0:00 ` Tom Moran
1997-10-03 0:00 ` Michael F Brenner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox