On Tue, Jun 24, 2008 at 02:27:04PM -0500, [EMAIL PROTECTED] wrote: > : =item rand > : > : our Num method rand ( Num $x: ) > : our Num term:<rand> > : > : Pseudo random number in range C<< 0 ..^ $x >>. That is, C<0> is > : theoretically possible, while C<$x> is not. The C<rand> function > : is 0-ary and always produces a number from C<0..^1>. > > Hmm, I'd've thought that meant that 'rand' takes no params and returns > 0..^1 but rand( Num $x: ) returns 0 .. ^$x but
The first rand is a method on the Num type. Since it's not specified as "is export", it remains strictly a method and doesn't supply a multisub form. > > : In any case, for picking a random integer you probably want to use > something like > : C<(1..6).pick> instead. > > There's some missing methods s not yet, I guess: > > ./perl6 -e 'say (1 .. 6).pick' > Method 'pick' not found for invocant of class 'Range' Correct, we haven't implemented .pick on Range objects yet. I'm not sure if we should have a separate .pick method for Range, or if List actually needs to be a role, or if there's some other role common to List and Range that should be providing .pick and other similar methods. > No 'pick' for Junction or any yet > ./perl6 -e 'my $i = one(1 .. 6).any + 0; say $i' > Method 'any' not found for invocant of class 'Junction' > > I tried a number whacks using prefix: > ./perl6 -e 'my $i = any(1 .. 6) ; say $i' > ./perl6 -e 'my $i = any(1 .. 6) + 0; say $i' > ./perl6 -e 'my @arr = (1 .. 6); my $i = any(1..6); say @arr[$i]' > > but no get_string or get_integer for Junction makes them a little hard to > use. Not complaining, just a note. get_string and get_integer on junction should autothread to their underlying components. We may have junction autothreading disabled at the moment in Rakudo. In particular, C< say any(1..6) > should result in six invocations of C<say>, one for each element in the Junction, each of those would then invoke get_string on the elements. Pm