Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^3: Converting python list range expressions to perl

by ibm1620 (Hermit)
on Dec 03, 2022 at 21:35 UTC ( [id://11148541]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    use v5.36;
    no warnings q/experimental/; # no warns about for-list
    ...
        my $join = join '', @$aref;
        printf("'$join', expecting '$answer'\n");
    }
    
  2. or download this
    a[3:] -> range(a, 3, undef) -> @a[3 .. 6] 'defg', expecting 'defg'
    a[0:] -> range(a, 0, undef) -> @a[0 .. 6] 'abcdefg', expecting 'abcdef
    +g'
    ...
    a[:3] -> range(a, undef, 3) -> @a[0 .. 2] 'abc', expecting 'abc'
    a[:0] -> range(a, undef, 0) -> @a[0 .. -1] '', expecting ''
    a[:-3] -> range(a, undef, -3) -> @a[0 .. 3] 'abcd', expecting 'abcd'
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11148541]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2024-04-16 16:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found