Re: my keeper on random numbers

2018-05-28 Thread ToddAndMargo
On 05/27/2018 11:38 PM, ToddAndMargo wrote: On 05/27/2018 04:17 PM, Brandon Allbery wrote: In the long form, yes. That's why the ^ shorthand exists. With the long form you have to start from an object of the same type to get to its metamodel, then pass the object you're actually asking about

Re: my keeper on random numbers

2018-05-28 Thread ToddAndMargo
On 05/27/2018 04:17 PM, Brandon Allbery wrote: In the long form, yes. That's why the ^ shorthand exists. With the long form you have to start from an object of the same type to get to its metamodel, then pass the object you're actually asking about to the metamodel method; the simplest way to

Re: my keeper on random numbers

2018-05-28 Thread ToddAndMargo
a larger number:     $ p6 'say 1000.rand;'     565.2817971799526 To convert to an positive integer, use truncate:     $ p6 'say 1000.rand.truncate;'     876 Follow up: This is my latest keeper on random numbers. In my program were I use this, I wanted a random positive four digit integer

Re: my keeper on random numbers

2018-05-27 Thread ToddAndMargo
On Sun, May 27, 2018 at 7:16 PM ToddAndMargo > wrote: On 05/27/2018 03:42 PM, Brian Duggan wrote: > ~ $ perl6 -e 'say 12.HOW.name (12)' > Int Does the "12" have to be repeated? On

Re: my keeper on random numbers

2018-05-27 Thread Brandon Allbery
In the long form, yes. That's why the ^ shorthand exists. With the long form you have to start from an object of the same type to get to its metamodel, then pass the object you're actually asking about to the metamodel method; the simplest way to do this is to reuse the same object. On Sun, May

Re: my keeper on random numbers

2018-05-27 Thread ToddAndMargo
On 05/27/2018 03:42 PM, Brian Duggan wrote: ~ $ perl6 -e 'say 12.HOW.name(12)' Int Does the "12" have to be repeated?

Re: my keeper on random numbers

2018-05-27 Thread ToddAndMargo
On 05/27/2018 03:42 PM, Brian Duggan wrote: On Sunday, May 27, ToddAndMargo wrote: Hi Brian, `^name` is sweet. Why the caret? (I realize it won't work without it.) The caret is shorthand for .HOW.name(object), i.e. ~ $ perl6 -e 'say 12.^name' Int same thing: ~ $

Re: my keeper on random numbers

2018-05-27 Thread Brian Duggan
On Sunday, May 27, ToddAndMargo wrote: > Hi Brian, > > `^name` is sweet. Why the caret? (I realize it won't work without it.) The caret is shorthand for .HOW.name(object), i.e. ~ $ perl6 -e 'say 12.^name' Int same thing: ~ $ perl6 -e 'say 12.HOW.name(12)'

Re: my keeper on random numbers

2018-05-27 Thread ToddAndMargo
On 05/27/2018 04:29 AM, Brian Duggan wrote: On Sunday, May 27, ToddAndMargo wrote: Why do I sometime see a range written `0..1000` and `0...1000` (three dots)? Two dots makes a Range. Three dots is the sequence operator -- it makes a Seq. ~ $ perl6 -e 'say (0..1000).^name'

Re: my keeper on random numbers

2018-05-27 Thread Brian Duggan
On Sunday, May 27, ToddAndMargo wrote: > Why do I sometime see a range written `0..1000` > and `0...1000` (three dots)? Two dots makes a Range. Three dots is the sequence operator -- it makes a Seq. ~ $ perl6 -e 'say (0..1000).^name' Range ~ $ perl6 -e 'say

Re: my keeper on random numbers

2018-05-26 Thread ToddAndMargo
On 05/26/2018 09:22 PM, ToddAndMargo wrote: Why the caret in `0..^1000`?  Why not `0..1000`? Figured that one out. The caret means to exclude the last number, so `0..^1000` is the same as `0..999` Thank you!

Re: my keeper on random numbers

2018-05-26 Thread ToddAndMargo
On 05/26/2018 09:09 PM, Brad Gilbert wrote: On Sat, May 26, 2018 at 10:59 PM, ToddAndMargo wrote: On 05/26/2018 05:10 AM, Brian Duggan wrote: To convert to an positive integer, use truncate: $ p6 'say 1000.rand.truncate;' 876 or use pick: perl6 -e 'say

Re: my keeper on random numbers

2018-05-26 Thread Brad Gilbert
On Sat, May 26, 2018 at 10:59 PM, ToddAndMargo wrote: > On 05/26/2018 05:10 AM, Brian Duggan wrote: >>> >>> To convert to an positive integer, use truncate: >>> $ p6 'say 1000.rand.truncate;' >>> 876 >> >> >> or use pick: >> >> perl6 -e 'say (^1000).pick' >> 209

Re: my keeper on random numbers

2018-05-26 Thread ToddAndMargo
On 05/26/2018 05:10 AM, Brian Duggan wrote: To convert to an positive integer, use truncate: $ p6 'say 1000.rand.truncate;' 876 or use pick: perl6 -e 'say (^1000).pick' 209 Brian Hi Brian, What does (^1000) mean? -T

Re: my keeper on random numbers

2018-05-26 Thread Brian Duggan
> To convert to an positive integer, use truncate: > $ p6 'say 1000.rand.truncate;' > 876 or use pick: perl6 -e 'say (^1000).pick' 209 Brian

my keeper on random numbers

2018-05-25 Thread ToddAndMargo
Hi All, This is my keep file submitted for your critique. Many thanks, -T Perl 6: random numbers: `rand` return a positive real number, always less than one: $ p6 'say rand;' 0.268091668368972 Place a number in front of it to get a larger number: $ p6 'say 1000.rand;'