Yes i know, this is terribly slow and so on. But i had some fun to play with it.
#!/usr/bin/env perl # $Id: 1196786.pl,v 1.3 2017/08/05 19:22:21 karl Exp karl $ # http://perlmonks.org/?node_id=1196786 use strict; use warnings; use Data::Dump qw(pp); use feature qw(say); my @points = ( [ 0, 0 ], [ -1, -2 ], [ 1, 2 ], [ -1, 2 ], [ 1, -2 ], [ 0, 1 ], [ 1, 0 ], [ -1, 0 ], [ 0, -1 ], [ 2147483647, 2147483647 ], [ 2147483647, -2147483647 ], [ -2147483647, 2147483647 ], [ -2147483647, -2147483647 ], ); kgb_str_look( kgb_str_hash() ); sub kgb_str_hash { my %cells = map { pp($_) => undef } @points; \%cells; } sub kgb_str_look { my $cells = shift; for (@points) { my $point = pp($_); ( exists $cells->{$point} ) ? say $point : die; } } __END__
Thanks for this interesting thread.
Best regards, Karl
«The Crux of the Biscuit is the Apostrophe»
perl -MCrypt::CBC -E 'say Crypt::CBC->new(-key=>'kgb',-cipher=>"Blowfish")->decrypt_hex($ENV{KARL});'Help
In reply to Re: Fastest way to lookup a point in a set
by karlgoethebier
in thread Fastest way to lookup a point in a set
by eyepopslikeamosquito
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |