What do you believe your $selection should mean? And I'm trying to figure out how to explain $limit since the one everyone else has used apparently means nothing whatsoever. Unless you've just been ignoring those as irrelevant, because it's not whatever you mean by "$selection" that nobody else can figure out.
Or is this still "words, and every other function that produces a list, is obviously also what indexes a list, therefore you pass into it the index you want from it"? How do you understand map() or grep() to work, if words() has to produce not a list but a specific item from that list? Call it once for every word in the list? On Wed, Sep 26, 2018 at 5:39 PM ToddAndMargo <toddandma...@zoho.com> wrote: > On 9/26/18 10:47 AM, The Sidhekin wrote: > > On Wed, Sep 26, 2018 at 8:58 AM Todd Chester <toddandma...@zoho.com > > <mailto:toddandma...@zoho.com>> wrote: > > > > Hi All, > > > > Over on > > https://docs.perl6.org/routine/words > > I see > > > > multi method words(Str:D $input: $limit = Inf --> Positional) > > > > HOW IN THE WORLD did they convert `$limit = Inf` into an > > array index!?!?! > > > > > > It's not. It's a limit: > > > > eirik@greencat[19:41:18]~$ perl6 -e '.say for "foo bar baz > qux".words(2)' > > foo > > bar > > eirik@greencat[19:41:29]~$ > > > > I see from your other email that you're using square brackets. > > That's what makes a zero-based index: > > > > eirik@greencat[19:41:29]~$ perl6 -e '.say for "foo bar baz > qux".words[2]' > > baz > > eirik@greencat[19:43:00]~$ > > > > But this index is not an argument to the words method. It is an > > argument to the .[ ] postcircumfix. > > > > That these are different things is perhaps more easily seen when > > they're both present: > > > > eirik@greencat[19:45:54]~$ perl6 -e '.say for "foo bar baz > > qux".words(3)[*-1]' > > baz > > eirik@greencat[19:45:59]~$ > > > > Here, it may be clearer that the $limit is 3, and the index is *-1. > > > > > > Eirik > > > Hi Eirik, > > Thank you for the explanation. > > I think I did not make myself clear. I do know how to > use the function and I use it all the time. > > What I don't understand is: > > multi method words(Str:D $input: $limit = Inf --> Positional) > > Specifically "$limit = Inf". Why are we using "$limit" instead > of "$selection" and why are we throwing "Inf" into the mix > as it is a "type". "Types" are written like "Str:D" and come > before the variable, not after. (I know the ":D" means "defined".) > > And where is it stated what goes in the () and what goes > in the []? > > Yours in frustration, > -T > -- brandon s allbery kf8nh allber...@gmail.com