Re: hash to hash reduction operator

2000-08-13 Thread Tom Hughes

In message [EMAIL PROTECTED]
  "Ed Mills" [EMAIL PROTECTED] wrote:

 Particularly useful for tied hashes using GDBM where the key is actually a
 compound key such as 'Tom Smith+Mycity+NY+13404' we could find all NY-ers
 using

   foreach (keys %h) {if (/\+NY\+/) {$h2{$_}=$h{$_}}

 but try it on 50,000 keys.. ACK, time for a coffee break.

It may not be helping that a list of the 5 keys is implicitly
constructed by that syntax. If we get iterator support in perl6 then
that should hopefully make it somewhat more efficient.

Tom

-- 
Tom Hughes ([EMAIL PROTECTED])
http://www.compton.nu/
...Geordi: "I'm too sexy for my beard."




hash to hash reduction operator

2000-08-11 Thread Ed Mills

I now you all will kill me for this but here goes..

this is slow:

  foreach (keys %h)
   {if (/some regex/) {$h2{$_}=$h{$_}}
   }

In other words, extract a new hash from an existing one by searching for 
primary keys matching a regex. (Please don't get off on your solutions to 
this or syntax corrctions- that's not the point of this message..)

Particularly useful for tied hashes using GDBM where the key is actually a 
compound key such as 'Tom Smith+Mycity+NY+13404' we could find all NY-ers 
using

  foreach (keys %h) {if (/\+NY\+/) {$h2{$_}=$h{$_}}

but try it on 50,000 keys.. ACK, time for a coffee break.

Now I'm not even sure what mechanism to ask for except something far more 
optimal be made available in the language. A way to slice it in n-space as 
opposed to n*n?

I guess what I really would need for speed is primary/secondary indices and 
I suspect the gentry here will (rightfully) send me packing for my MySQL 
DBI. But I thought I'd suggest this possibility since Larry said this is a 
brainstorming exercise right now.

Something like secondary indices for hashes of hashes perhaps?

Ducking and covering..







Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com