On Fri, 1 Jan 2021 at 18:59, ToddAndMargo via perl6-users <perl6-us...@perl.org <mailto:perl6-us...@perl.org>> wrote:

     >>     ^ note: ^3 means the integer "just before" 3  (zero is
    presume to be the
     >>     start point)
     >>
     >>                3^ means the integer "just after" 3  (an ending
    point is
     >>     required)
     >>
     >>

    On 12/31/20 10:15 PM, Kevin Pye wrote:
     > No, it does not. Go back and read what Brad wrote; he was quite
    explicit.
     >
     > Nothing about the range 0 ..^ 3 (for which "^3" is just a short-cut)
     > says anything about integers. It is the range of numbers (real
    numbers
     > if you like) ranging from 0 to 3, but excluding 3. In standard
     > mathematical notation that would be "[0,3)". If you iterate over the
     > range then you start with the beginning of the range and keep
    adding one
     > until you reach the end (in this case ignoring the final value if
    it is
     > equal to the end-point).
     >
     > If the range were 0.5 .. 3 then the iterated values would be 0.5,
    1.5
     > and 2.5.


    Hi Kevin,

    My notes were for "for" loops.

         > for ^2 {print "$_\n";}
         0
         1


    I am not able to reproduce your comments:

         > for ^2.1..2.5 {print "$_\n";}
         Range objects are not valid endpoints for Ranges
           in block <unit> at <unknown file> line 1

         > for ^2.1 .. 2.5 {print "$_\n";}
         Range objects are not valid endpoints for Ranges
           in block <unit> at <unknown file> line 1

    Would you mind throwing me an REPL example?

    Many thanks,
    -T

On 1/1/21 12:39 AM, Kevin Pye wrote:
 We have established that ^2.1 is a range, meaning all the real numbers from 0 to 2.1, not including the 2.1.

What do you expect ^2.1 .. 2.5 to mean, That's a range (the "..") from "^2.1", another range to the number 2.5. You can't have a range starting with a range, A range is between two numbers. Hence the error message is quite correct.

There are four infix operators which create ranges: "..", "^..", "..^" and "^..^"
and the prefix operator "^:"; you're trying to mix two of them.

All of those take numbers as their arguments, not ranges.

Try something like

.say for 2.1 .. 2.5

You can try
.say for 2.1 ^.. 2.5

> .say for 2.1 .. 2.5
2.1


> .say for 2.1 .. ^2.5
Range objects are not valid endpoints for Ranges
  in block <unit> at <unknown file> line 1


and then explain the output.

Hi Kevin,

I am trying to get it to work in a "for" loop.

I am doing something wrong.

Would you mind sending me the proper syntax
for this from REPL?

-T




Reply via email to