Jump to content

Multiple distinct objects: Difference between revisions

m
→‎{{header|REXX}}: chaned program so that it wouldn't raise the NOVALUE condition, add the displaying or more information.
(Replaced existing text which contained errors by an example.)
m (→‎{{header|REXX}}: chaned program so that it wouldn't raise the NOVALUE condition, add the displaying or more information.)
Line 1,221:
<lang rexx>/*REXX program does a list comprehension that will create N random integers, all unique.*/
parse arg n lim . /*obtain optional argument from the CL.*/
if n=='' | n=="," then n= 20 1000 /*Not specified? Then use the default.*/
if lim=='' | lim=="," then lim= 100000 /* " " " " " " */
lim= min(lim, 1e5) /*limit the random range if necessary. */
randoms= /*will contain random list of integers.*/
$= .
#= 0 /*counter used to ensure uniqueness. */
do j=1 for n /*gen a unique random integer for list.*/
 
do until wordpos(?, @)==0 /*ensure " " " " " */
do until ?= randomwordpos(0$, 100000randoms)==0 /*ensure " " " /*Not unique?" Then obtain another" int.*/
$= random(0, lim) end /*until*/ /*100KNot isunique? the maximumThen rangeobtain foranother RANDOMint.*/
@= @ ? end /*until*/ /*add100K anis uniquethe randommaximum integerrange tofor listRANDOM.*/
 
end /*j*/ /*stick a fork in it, we're all done. */</lang>
randoms= $ randoms /*add an unique random integer to list.*/
<br><br>
end /*j*/
 
say words(randoms) ' unique numbers end /*j*/ generated.' /*stick a fork in it, we're all done. */</lang>
<br><br>
 
=={{header|Ruby}}==
Cookies help us deliver our services. By using our services, you agree to our use of cookies.