Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^2: Need help with range expression ('0 .. -0.5' === '0 .. 0.5')

by BillKSmith (Parson)
on Feb 24, 2019 at 04:41 UTC ( #1230483=note: print w/replies, xml ) Need Help??


in reply to Re: Need help with range expression ('0 .. -0.5' === '0 .. 0.5')
in thread [SOLVED]: Need help with range expression ('0 .. -0.5' === '0 .. 0.5')

I am surprised that this works for the special case qw(A). Documentation for the range operator specifies that it returns an empty list when the first element is greater than the second (in this case 0..-1). I cannot find any documentation of what should happen when the list of elements in an array slice is an empty list (in this case @a() ). It seems to return an empty string, which is exactly what is needed!

UPdate: Corrected terminology - Changed 'string' to 'list'.

Bill
  • Comment on Re^2: Need help with range expression ('0 .. -0.5' === '0 .. 0.5')

Replies are listed 'Best First'.
Re^3: Need help with range expression ('0 .. -0.5' === '0 .. 0.5')
by vr (Deacon) on Feb 24, 2019 at 06:36 UTC

    No, why (from Range Operators):

    In list context, it returns a list of values counting (up by ones) from the left value to the right value. If the left value is greater than the right value then it returns the empty list.

    I'm embarrassed to see now, I posted almost the same answer as poj 10 minutes after him. I guess I just glanced across available answers without actually reading, thought his was long enough so mine is different, and clicked "create". Sorry about that.

      I had already found the pertinent documentation for the range operator (thanks for posting the link). I still cannot find documentation for the special case of array slice.
      Bill

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2019-06-27 08:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Is there a future for codeless software?



    Results (111 votes). Check out past polls.

    Notices?