develooper Front page | perl.perl6.users | Postings from February 2019

Re: split and nils?

Thread Previous | Thread Next
From:
ToddAndMargo via perl6-users
Date:
February 6, 2019 22:36
Subject:
Re: split and nils?
Message ID:
5e56dd2b-a038-ca7f-d5a5-390de5028c08@zoho.com
On 2/6/19 12:17 PM, yary wrote:
> 
> On Wed, Feb 6, 2019, 11:57 AM ToddAndMargo via perl6-users 
> <perl6-users@perl.org <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 `split`.
> 
> # these are all identical
> 'abcd'.comb.kv
> 'abcd'.comb(1).kv
> comb( 1, 'abcd' ).kv



And you read through my typos too!

$ p6 'my Str $x="abcd"; for $x.comb.kv -> $i, $j {say "Index <$i> = <$j> 
= ord <" ~ ord($j) ~ ">";}'

Index <0> = <a> = ord <97>
Index <1> = <b> = ord <98>
Index <2> = <c> = ord <99>
Index <3> = <d> = ord <100>

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About