RandomTools Flavor: integer - Maple Programming Help

Home : Support : Online Help : Programming : Random Objects : RandomTools package : Flavors : RandomTools/flavor/integer

RandomTools Flavor: integer

describe a flavor of a random integer

 Calling Sequence integer integer(opt)

Parameters

 opt - equation of the form range = value; specify options for the random integer

Description

 • The flavor integer describes a random integer in a particular range.
 To describe a flavor of a random integer, use either integer or integer(opt) (where opt is as described below) as the argument to RandomTools[Generate] or as part of a structured flavor.
 • By default, the flavor integer describes a random integer in the range $-499999999994..499999999994$, inclusive.
 • You can modify the properties of the random integer by using the integer(opt) form of this flavor. The opt argument can contain one or more of the following equations.
 range = a..b
 This option specifies the range from which the random integer is chosen.
 The endpoints must be of type integer and they describe a random integer in the interval $a..b$, inclusive.
 If the left-hand endpoint of the range is greater than the right-hand endpoint, an exception is raised.
 exclude= {n1,n2,...}
 This option specifies one or more individual integers that should be excluded from the possible return values.

Examples

 > $\mathrm{with}\left(\mathrm{RandomTools}\right):$
 > $\mathrm{Generate}\left(\mathrm{integer}\right)$
 ${-104281139460}$ (1)
 > $\mathrm{Generate}\left(\mathrm{integer}\left(\mathrm{range}=2..7\right)\right)$
 ${3}$ (2)
 > $\mathrm{seq}\left(\mathrm{Generate}\left(\mathrm{integer}\right),i=1..10\right)$
 ${-306860183579}{,}{-477575829529}{,}{300187484465}{,}{-72447943125}{,}{342622684448}{,}{-87713714154}{,}{496417214186}{,}{-113591692544}{,}{194607189271}{,}{273012980029}$ (3)
 > $\mathrm{Generate}\left(\mathrm{list}\left(\mathrm{integer}\left(\mathrm{range}=-5..5\right),10\right)\right)$
 $\left[{5}{,}{-3}{,}{3}{,}{4}{,}{-4}{,}{5}{,}{2}{,}{4}{,}{3}{,}{5}\right]$ (4)
 > $\mathrm{Matrix}\left(3,3,\mathrm{Generate}\left(\mathrm{integer}\left(\mathrm{range}=2..7\right)\mathrm{identical}\left(x\right)+\mathrm{integer}\left(\mathrm{range}=2..7\right),\mathrm{makeproc}=\mathrm{true}\right)\right)$
 $\left[\begin{array}{ccc}{2}{}{x}{+}{7}& {6}{}{x}{+}{7}& {5}{}{x}{+}{4}\\ {7}{}{x}{+}{6}& {4}{}{x}{+}{6}& {5}{}{x}{+}{4}\\ {3}{}{x}{+}{4}& {2}{}{x}{+}{2}& {4}{}{x}{+}{6}\end{array}\right]$ (5)
 > $\mathrm{Generate}\left(\mathrm{integer}\left(\mathrm{range}=-10..10,\mathrm{exclude}=\left\{0,1,-1\right\}\right)\right)$
 ${-6}$ (6)
 > $\mathrm{seq}\left(\mathrm{Generate}\left(\mathrm{integer}\left(\mathrm{range}=-5..5,\mathrm{exclude}=\left\{0,1,-1\right\}\right)\right),i=1..20\right)$
 ${4}{,}{4}{,}{4}{,}{5}{,}{-4}{,}{2}{,}{-2}{,}{-4}{,}{3}{,}{3}{,}{-2}{,}{-3}{,}{4}{,}{3}{,}{4}{,}{5}{,}{-2}{,}{3}{,}{2}{,}{3}$ (7)