comp.lang.ada
 help / color / mirror / Atom feed
From: "John B. Matthews" <nospam@nospam.invalid>
Subject: Re: Random number generation
Date: Tue, 13 Jul 2010 16:33:39 -0400
Date: 2010-07-13T16:33:39-04:00	[thread overview]
Message-ID: <nospam-A035A2.16333613072010@reserved-multicast-range-NOT-delegated.example.com> (raw)
In-Reply-To: i1i3cc$8ro$1@tornado.tornevall.net

In article <i1i3cc$8ro$1@tornado.tornevall.net>,
 "Jeffrey R. Carter" <spam.jrcarter.not@spam.acm.org> wrote:

> On 07/13/2010 05:45 AM, tonyg wrote:
> > I want to generate a random integer and a random floating point 
> > number between 10 and 30 . I've been looking at previous posts and 
> > finding it a little confusing with many packages, has anyone an 
> > already done example in ada 2005 they can post up?

Here's an Ada 95 example that uses Ada.Numerics.Discrete_Random to 
simulate repeated plays of a simple card game:

<http://home.roadrunner.com/~jbmatthews/war.html>

The shuffling algorithm needs work; this might be an alternative:

<http://en.wikipedia.org/wiki/Fisher–Yates_shuffle>

> The random integer is pretty easy to do with an appropriate [sub]type 
> and Ada.Numerics.Discrete_Random. The random floating-point is a bit 
> more difficult, and there's always the question of whether 30.0 must 
> be a possible value. You can have a look at Random_Range in 
> PragmARC.Universal_Random:
> 
> http://pragmada.x10hosting.com/pragmarc.htm

As an aside, Mine Detector V6.0 builds on Mac OS X 10.5.8 with GtkAda 
2.14.1 and GNAT 4.3.4. Wait, I took a picture:

<http://i26.tinypic.com/23qyxxi.png>

-- 
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>



  reply	other threads:[~2010-07-13 20:33 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-13 12:45 Random number generation tonyg
2010-07-13 12:50 ` Jacob Sparre Andersen
2010-07-13 12:58 ` Dmitry A. Kazakov
2010-07-13 13:17 ` Thomas Løcke
2010-07-13 16:07 ` Jeffrey R. Carter
2010-07-13 20:33   ` John B. Matthews [this message]
2010-07-13 23:02     ` Jeffrey R. Carter
2010-07-14  4:42       ` John B. Matthews
2010-07-15 19:01         ` tonyg
  -- strict thread matches above, loose matches on Subject: below --
2010-12-30 10:43 Mart van de Wege
2010-12-30 10:54 ` Thomas Løcke
2010-12-30 12:11   ` Mart van de Wege
2010-12-30 11:34 ` Niklas Holsti
2010-12-30 11:53   ` Georg Bauhaus
2010-12-30 12:25     ` Mart van de Wege
2010-12-30 15:29       ` Georg Bauhaus
2010-12-30 15:37         ` Mart van de Wege
2010-12-30 11:51 ` Brian Drummond
2010-12-30 12:16   ` Mart van de Wege
2010-12-30 13:04 ` Dmitry A. Kazakov
2010-12-30 13:22   ` Niklas Holsti
2010-12-30 13:39     ` Dmitry A. Kazakov
2010-12-30 13:30   ` Mart van de Wege
2010-12-31  3:14 ` Gene
2003-09-26  7:14 random " christoph.grein
2003-09-26  7:00 Andrew
2003-09-26  7:35 ` tmoran
2003-09-26 17:58   ` Andrew
2003-09-26 19:25   ` Andrew
2003-09-26 19:35     ` chris
2003-09-26 21:44     ` tmoran
2003-09-27  1:40     ` Robert I. Eachus
2003-09-27  4:48       ` Andrew
1997-12-19  0:00 Mok-kong Shen
1998-01-02  0:00 ` Mok-kong Shen
1998-01-02  0:00   ` Robert Dewar
1996-10-13  0:00 Random Number Generation parker
1996-10-13  0:00 ` Robert Dewar
1996-10-14  0:00 ` Robert A Duff
1996-10-10  0:00  Dr J Parker
1996-10-10  0:00  Dr J Parker
1996-10-12  0:00 ` Keith Thompson
1996-10-12  0:00 ` Geert Bosch
1996-10-02  0:00  Dr J Parker
1996-10-03  0:00 ` Mats Weber
1996-10-07  0:00 ` Geert Bosch
1996-09-23  0:00 Nigel J. Tracey
1996-09-23  0:00 ` Tucker Taft
1996-10-02  0:00   ` Nigel J. Tracey
1996-10-02  0:00   ` Robert I. Eachus
1996-10-03  0:00   ` Nigel J. Tracey
1996-09-25  0:00 ` James_Rogers
1996-09-26  0:00   ` Dale Stanbrough
1996-10-01  0:00   ` Robert I. Eachus
1996-09-30  0:00 `  Dr J Parker
1996-10-01  0:00   ` Tucker Taft
1996-10-01  0:00     ` Keith Thompson
replies disabled

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