comp.lang.ada
 help / color / mirror / Atom feed
* Random Number Generator
  1998-11-13  0:00 (no subject) niel.williams
@ 1998-11-13  0:00 ` John Herro
  0 siblings, 0 replies; 4+ messages in thread
From: John Herro @ 1998-11-13  0:00 UTC (permalink / raw)



"niel.williams" <niel.williams@virgin.net> writes:
> Has any one got a simple random number
> generator prog that generates numbers
> between 1-10?

If you have an Ada 95 compiler, the answer is simply to use the package
Ada.Numerics.Discrete_Random, which comes with the language.  This program
keeps displaying random integers from 1 to 10:

with Ada.Text_IO, Ada.Numerics.Discrete_Random;
use  Ada.Text_IO;
procedure Test is
  subtype S is Integer range 1 .. 10;
  package My_Random is new
       Ada.Numerics.Discrete_Random(S);
  use My_Random;
  G : Generator;
begin
  Reset(G);
  loop
    Put(Integer'Image(Random(G)));
  end loop;
end Test;

If you have an Ada 83 compiler, the answer is much more complicated, but the
compiler *may* have come with a package to do what you want.

- John Herro
You can download a shareware Ada Tutor program at
http://members.aol.com/AdaTutor




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

* Re: Random Number Generator
  2000-02-26  0:00 Random Number Generator Hustler
@ 2000-02-26  0:00 ` David C. Hoos, Sr.
  2000-02-28  0:00 ` Robert Dewar
  1 sibling, 0 replies; 4+ messages in thread
From: David C. Hoos, Sr. @ 2000-02-26  0:00 UTC (permalink / raw)



Hustler <bdowney@wvu.edu> wrote in message
news:8981l1$1dfqk$1@homer.cfw.com...
> Does anyone know where the number generator is located, ie the package? Is
> it in ada.elementary_functions packages or do I need to find a package
that
> contains a random number generator?
For pseudo-random floating-point random numbers, it's in the package
Ada.Numerics.Float_Random.  For pseudo-random integers and enumeration type
it's in the package Ada.Numerics.Discrete_Random.








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

* Random Number Generator
@ 2000-02-26  0:00 Hustler
  2000-02-26  0:00 ` David C. Hoos, Sr.
  2000-02-28  0:00 ` Robert Dewar
  0 siblings, 2 replies; 4+ messages in thread
From: Hustler @ 2000-02-26  0:00 UTC (permalink / raw)


Does anyone know where the number generator is located, ie the package? Is
it in ada.elementary_functions packages or do I need to find a package that
contains a random number generator?

Thanks for the help
Brandon






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

* Re: Random Number Generator
  2000-02-26  0:00 Random Number Generator Hustler
  2000-02-26  0:00 ` David C. Hoos, Sr.
@ 2000-02-28  0:00 ` Robert Dewar
  1 sibling, 0 replies; 4+ messages in thread
From: Robert Dewar @ 2000-02-28  0:00 UTC (permalink / raw)


In article <8981l1$1dfqk$1@homer.cfw.com>,
  "Hustler" <bdowney@wvu.edu> wrote:
> Does anyone know where the number generator is located, ie the
package? Is
> it in ada.elementary_functions packages or do I need to find a
package that
> contains a random number generator?
>
> Thanks for the help
> Brandon


Here's how you can answer a straightforward question like this
instantaneously for yourself.

Get an electronic copy of the Ada 95 RM (you can find this at
www.adapower.com for example).

Then search for the string "random" or else look up Random
in the index. Either approach will lead you to the appropriate
package immediately.


Sent via Deja.com http://www.deja.com/
Before you buy.




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

end of thread, other threads:[~2000-02-28  0:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-02-26  0:00 Random Number Generator Hustler
2000-02-26  0:00 ` David C. Hoos, Sr.
2000-02-28  0:00 ` Robert Dewar
  -- strict thread matches above, loose matches on Subject: below --
1998-11-13  0:00 (no subject) niel.williams
1998-11-13  0:00 ` Random Number Generator John Herro

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