> Also, if the set consists of small integers, and you
> don't want to iterate over them, then it may be better
> to use an array like
>
> my @set;
> sub contains { @set{$_[0]}; }
> sub add { @set{$_[0]} = 1; }
It seems -- from the operations in the subs -- you have declared a hash called %set somewhere not shown. That, or you are confused about the hash and array operations, in which case correct syntax for working w/ the array would be ...
sub contains { $set[ $_[0] ]; } sub add { $set[ $_[0] ] = 1; }
- parv
In reply to Re^2: Hash Set
by parv
in thread Hash Set
by tomazos
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |