On 9/26/18 5:57 PM, Brandon Allbery wrote:
On Wed, Sep 26, 2018 at 8:49 PM ToddAndMargo <toddandma...@zoho.com <mailto:toddandma...@zoho.com>> wrote:


    $ p6 '"a b c d e".words[ 2, 4 ].say;'
    (c e)

    or

    $ p6 '"a b c d e".words()[ 2, 4 ].say;'
    (c e)

    I am selecting the 2nd and 4th word starting from zero.  Inside
    the brackets I am asking it to select th e 2nd and 4th words for me.

    I am NOT asking it to limit my request to Infinity.


Correct. You put them inside the [ ]. They belong to the [ ] role of Positional. The words function knows nothing whatsoever about this. It belongs to Positional.

If you put it inside the parentheses instead of the brackets, it belongs to the Callable, and will be given to words(). Now it is applied as the $limit on how many times to split the string.

    Where does it state that

    $ p6 '"a b c d e".words(3).say;'
    (a b c)

    means the first three words, starting at zero?


At least three of us have told you that this is $limit, because it is in the parentheses instead of in the brackets. But you want words() to have a $selection there instead, so words() can be a list for you instead of letting the list be a list. Why is it so important that words() pretend to be a list, when we have lists that know how to be lists? Why is it so important that you not have to find out what a list is, but instead that words() must pretend that it is a list?

Nobody understands why you insist that lists are wired into the functions that produce them and can't possibly know that they can be indexed. And that we must document every function that produces a listas actally itself being a list, including magical $selection parameters, when that is what lists are for. What do you think lists are for, if words() and lines() have to be fake lists to work instead of producing real lists?

Hi Brandon,

Curt explained it to me.

To go along with what you stated

    $ p6 '"a b c d e".words(3)[ 2, 4 ].say;'
    (c Nil)

"words" is returning the first three words delimited
by whitespace.  [2,4] is request the individual words
in positions 2 and 4 starting at 0.  The "Nil" is because
there are only three words after requesting the (3).

Thank you for all the help with this!

-T

Reply via email to