Re: split and nils?

2019-02-07 Thread Brad Gilbert
First off a Str is a singular value, not a list. Which is a good thing. my $a = "abc"; my $b = "\c[COMBINING ACUTE ACCENT]"; say $a.chars; # 3 say $b.chars; # 1 If they were a list, then combining them should create something that is 4 chars long, but it doesn't. say ($a ~

Re: split and nils?

2019-02-06 Thread ToddAndMargo via perl6-users
On 2/6/19 12:17 PM, yary wrote: On Wed, Feb 6, 2019, 11:57 AM ToddAndMargo via perl6-users mailto:perl6-users@perl.org>> said What would be the most practice way of converting a string to and array of characters Brad said- You should be using `comb` if you want a list of characters not

Re: split and nils?

2019-02-06 Thread yary
On Wed, Feb 6, 2019, 11:57 AM ToddAndMargo via perl6-users < perl6-users@perl.org> said What would be the most practice way of converting a string to and array of characters Brad said- You should be using `comb` if you want a list of characters not `split`. # these are all identical

Re: split and nils?

2019-02-06 Thread ToddAndMargo via perl6-users
On Wed, Feb 6, 2019 at 1:02 PM ToddAndMargo via perl6-users mailto:perl6-users@perl.org>> wrote: On 2/6/19 12:58 PM, Patrick R. Michaud wrote: > On Wed, Feb 06, 2019 at 12:38:01PM -0800, ToddAndMargo via perl6-users wrote: >> $ p6 'my Str $x="abcd"; for $x.comb.kv -> $i, $j

Re: split and nils?

2019-02-06 Thread yary
Leave off the '.kv' to get a Seq (array-like-thing) > my $letters='abc def g'; abc def g > $letters.comb().perl ("a", "b", "c", " ", "d", "e", "f", " ", "g").Seq > ($letters.comb())[0,3,4,6] (a d f) > my @letter_array = $letters.comb() [a b c d e f g] > @letter_array[1] b -y On

Re: split and nils?

2019-02-06 Thread ToddAndMargo via perl6-users
On 2/6/19 12:58 PM, Patrick R. Michaud wrote: On Wed, Feb 06, 2019 at 12:38:01PM -0800, ToddAndMargo via perl6-users wrote: $ p6 'my Str $x="abcd"; for $x.comb.kv -> $i, $j {say "Index <$i> = <$j> = ord <" ~ ord($j) ~ ">";}' Index <0> = = ord <97> Index <1> = = ord <98> Index <2> = = ord

Re: split and nils?

2019-02-06 Thread Patrick R. Michaud
On Wed, Feb 06, 2019 at 12:38:01PM -0800, ToddAndMargo via perl6-users wrote: > $ p6 'my Str $x="abcd"; for $x.comb.kv -> $i, $j {say "Index <$i> = <$j> = > ord <" ~ ord($j) ~ ">";}' > > Index <0> = = ord <97> > Index <1> = = ord <98> > Index <2> = = ord <99> > Index <3> = = ord <100> > >

Re: split and nils?

2019-02-06 Thread ToddAndMargo via perl6-users
On 2/6/19 5:19 AM, Brad Gilbert wrote: > The reason there is a Nil, is you asked for the ord of an empty string. > > "".ord =:= Nil > > The reason there are two empty strings is you asked for them. What would be the most practice [practical] way of

Re: split and nils?

2019-02-06 Thread Laurent Rosenfeld via perl6-users
Brad told you already: use comb. Le mer. 6 févr. 2019 à 20:57, ToddAndMargo via perl6-users < perl6-users@perl.org> a écrit : > On 2/6/19 5:19 AM, Brad Gilbert wrote: > > The reason there is a Nil, is you asked for the ord of an empty string. > > > > "".ord =:= Nil > > > > The reason there

Re: split and nils?

2019-02-06 Thread ToddAndMargo via perl6-users
On 2/6/19 5:19 AM, Brad Gilbert wrote: The reason there is a Nil, is you asked for the ord of an empty string. "".ord =:= Nil The reason there are two empty strings is you asked for them. What would be the most practice way of converting a string to and array of characters? $x="abc"

Re: split and nils?

2019-02-06 Thread ToddAndMargo via perl6-users
> On Tue, Feb 5, 2019 at 11:05 PM ToddAndMargo via perl6-users > wrote: >> >> Hi All, >> >> What is with the starting ending Nils? There are only four >> elements, why now six? >> >> And how to I correct this? >> >> $ p6 'my Str $x="abcd"; >>for split( "",@$x ).kv -> $i,$j { >>

Re: split and nils?

2019-02-06 Thread Brad Gilbert
The reason there is a Nil, is you asked for the ord of an empty string. "".ord =:= Nil The reason there are two empty strings is you asked for them. When you split with "", it will split on every character boundary, which includes before the first character, and after the last. That's

split and nils?

2019-02-05 Thread ToddAndMargo via perl6-users
Hi All, What is with the starting ending Nils? There are only four elements, why now six? And how to I correct this? $ p6 'my Str $x="abcd"; for split( "",@$x ).kv -> $i,$j { say "Index <$i> = <$j> = ord <" ~ ord($j) ~ ">";}' Use of Nil in string context in block at -e line 1