Re: my keeper on random numbers

2018-05-27 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-27 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-27 Thread ToddAndMargo
On 05/25/2018 09:19 PM, ToddAndMargo wrote: 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

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 05/27/2018 04:17 PM, Brandon Allbe

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 2

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: ~ $ p

Re: Real, Num, Rat question

2018-05-27 Thread ToddAndMargo
On Sun, May 27, 2018 at 5:50 PM ToddAndMargo > wrote: Hi All, What is wrong with this picture? Is my type being changed or are "Num" and "Rat" in a subset of "Real"? Also, what do I alter to get ^name to say real? $ p6 'my Real $x= 5e65; s

Re: Real, Num, Rat question

2018-05-27 Thread ToddAndMargo
> On Sun, May 27, 2018 at 2:49 PM, ToddAndMargo > wrote: > > Hi All, > > What is wrong with this picture? Is my > type being changed or are "Num" and "Rat" in > a subset of "Real"? > > Also, what do I alter to get ^name to say real? > > $ p6

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)' Int

Re: Real, Num, Rat question

2018-05-27 Thread Brent Laabs
Real is a role, not a type. Both Num and Rat happen to do Real, so the type checking is ok. This would work OK with a type too -- you can safely store a Num in a `my Cool $foo` as well. You can't do anything to make the ^name method return Real. There are a few ways to check this, though. The

Re: Real, Num, Rat question

2018-05-27 Thread Brandon Allbery
"Real" is a role (a collection of common methods reusable by multiple classes/types), not itself a class/type. Similarly, "Positional" is a role which provides common methods to "Array", "List", and "Seq" among others. On Sun, May 27, 2018 at 5:50 PM ToddAndMargo wrote: > Hi All, > > What is wro

Real, Num, Rat question

2018-05-27 Thread ToddAndMargo
Hi All, What is wrong with this picture? Is my type being changed or are "Num" and "Rat" in a subset of "Real"? Also, what do I alter to get ^name to say real? $ p6 'my Real $x= 5e65; say $x.^name' Num $ p6 'my Real $x= 5.5; say $x.^name' Rat Many thanks, -T

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' Ra

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 (0...1000).^n