[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]
Re: arrays: delete()/exists() + possible keys()/values()
On Fri, Jan 14, 2000 at 12:21:41AM -0500, "Chip Turner" wrote:
> "Mark Mielke" <markm@nortelnetworks.com> writes:
> > Let's see... what were the other operators? each()?
> > my @a;
> > $a[5] = 2;
> > $a[7] = 3;
> > while (($k, $v) = each @a) {
> > print "\$a[$k] = $v;\n";
> > }
> > Would Print:
> > $a[5] = 2;
> > $a[7] = 3;
> I've often thought about things like:
> my @a = (1, 2, 3, 4);
> my %a = @a;
> The nice thing about this is that if...
> my %a = @a;
> Then we have keys(%a) being the same (except for ordering) as keys
> @a. Likewise for values.
Hmm... Either one would suit me fine for elegance, but I'm still leaning
towards keys(@array) returning the list of valid "keys" that can be used
on @array. keys(@array) to me doesn't say "if @array were to be co-erced
into being a hash, what would the keys() of that hash be"... it says "look
at @array as if it already is a hash, what would the keys() of that hash be."
An array is just a hash optimized for space, speed, and ordering, with the
only restriction being that it is now indexed by an integer instead of a
string.
mark
--
markm@nortelnetworks.com/mark@mielke.cc/markm@ncf.ca __________________________
. . _ ._ . . .__ . . ._. .__ . . . .__ | SIR Tools (7H12)
|\/| |_| |_| |/ |_ |\/| | |_ | |/ |_ | Nortel Networks
| | | | | \ | \ |__ . | | .|. |__ |__ | \ |__ | Ottawa, Ontario, Canada
One ring to rule them all, one ring to find them, one ring to bring them all
and in the darkness bind them...
http://mark.mielke.cc/
- References to:
-
Tom Christiansen <tchrist@chthon.perl.com>
"Mark Mielke" <markm@nortelnetworks.com>
Chip Turner <chip@zfx.com>
[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]