Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^11: Is there any difference between prototype % and @ ?

by AnomalousMonk (Chancellor)
on Feb 23, 2013 at 16:56 UTC ( #1020324=note: print w/replies, xml ) Need Help??


in reply to Re^10: Is there any difference between prototype % and @ ?
in thread Is there any difference between prototype % and @ ?

it's a common idiom to use map to create listified hashes map { $_ => 0 } LIST

A hash is commonly initialized from a list, e.g.
    my %hash = qw(a 1  b 2  c 3);
Does the quoted idiom do anything other than generate another list with which to initialize a hash? Can a hash so initialized be considered in any way distinct from a hash created in any other way; in particular, can it usefully be distinguished as 'listified'?

orthogonality always makes sense!

A hash is commonly initialized from a list as in the example given above, and a hash is seamlessly 'listified' in list context as in a statement like
    print %hash;
or
    my @array = %hash;
but are lists (and, by extension, arrays) really orthogonal with hashes? Despite certain conceptual similarities, my inclination would be to say no: there are just too many differences:

  • A hash can be assigned to an array and all the information inherent in the hash can be accessed and manipulated using standard array and list operators, but this is rarely anything other than an exercise in masochism;
  • An array can be assigned to a hash, but the information inherent in the array is largely destroyed thereby.

Prototypes are just not mature enough!!!

Amen to that, brother! Or rather, they are just not well-named enough. Had they been better named, people like myself who come from C/C++land and adjacent regions would not know instantly what they are – and be instantly wrong!

Replies are listed 'Best First'.
Re^12: Is there any difference between prototype % and @ ?
by LanX (Chancellor) on Feb 23, 2013 at 18:17 UTC
    simple test, try to chain my and BUKs implementation of hgrep, 2 in a row!

    I'll try to propose a solution for all of this including lazy lists after GPW in March.

    Cheers Rolf

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1020324]
help
Chatterbox?
[marto]: "Eugenie Scott, executive director of the National Center for Science Education, dubbed this approach the Gish gallop, describing it as "where the creationist is allowed to run on for 45 minutes or an hour, spewing forth torrents of error that the
[marto]: evolutionist hasn't a prayer of refuting in the format of a debate." She also criticized Gish for failing to answer objections raised by his opponents"
[erix]: one would hope evolutionists haven't any prayers anyway
[marto]: obviously someone could be religious, but not creationist
[erix]: "Nothing in Intelligent Design makes sense except in the light of Creationism" <-- I made that one up myself (free after Dobzhansky )
[erix]: yes. Deplorable marto, deplorable.
[marto]: the situation seemed similar to this one, majority of the contributrions are nonsense, doesn't address any questions ...
[marto]: meh, I've been called worse :P

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (12)
As of 2017-07-28 15:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I came, I saw, I ...
























    Results (431 votes). Check out past polls.