Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^4: Fastest way to lookup a point in a set

by swl (Parson)
on Aug 07, 2017 at 09:19 UTC ( [id://1196889]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Fastest way to lookup a point in a set
in thread Fastest way to lookup a point in a set

There is also the issue of locales and the radix char when non-integer values are used with multidimensional hash keys.

If one has coordinates

[5, 5.5] [5.5, 5 ]
then using the multidimensional hash approach in a locale where both $; and the radix char are a comma would result in ambiguous keys:
{5,5,5} {5,5,5}

I know the original post specifies signed ints, so I'm just being more generic here. I also haven't checked if there is locale specific behaviour of $;

Replies are listed 'Best First'.
Re^5: Fastest way to lookup a point in a set
by LanX (Saint) on Aug 07, 2017 at 10:17 UTC
    From the docs: The default subscript separator is "\034", the same as SUBSEP in awk

    It's not "," , that's just the placeholder in Perl's syntax.

    I don't know and can't think of any number format or localization which uses chr(28) .

    Printable characters start from chr(32) onwards.

    update

    to avoid confusion

    hex, oct, dez

    perl -e "print 0x1c,034,28" 282828

    Cheers Rolf
    (addicted to the Perl Programming Language and ☆☆☆☆ :)
    Je suis Charlie!

      Thanks for clarifying.

      Here are some more examples for those reading later and who haven't previously had to work with non-printing characters in this way (e.g. me a few hours ago):

      # default $; does not print perl -e 'print join $;, 1..5' 12345 # but $; is still in the string perl -e '@x = split ($;, join ($;, 1..5)); print join ":", @x' 1:2:3:4:5

      That still does leave the issue of debugging using print statements, as [5,55] and [55,5] will both print as 555 on a terminal. The point is effectively moot, though, as the other posts have shown multidimensional indexing is slower and should probably not be used in this case.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (9)
As of 2024-04-23 09:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found