Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Maybe it's just that I was a math major, or got too close to those whacky Haskell nuts, but map has always seemed a very natural metaphor for me. (It's the natural extension of a function on a space A to the space An)

However, this (map is natural instead of foreach) is only true when the expression inside the map isn't itself accumulating side-effects; e.g. the following useage of map doesn't seem natural:

my $i=0; map {$keywordhash{$_}=(++$i);} @keywords;
However, this useage seems quite natural:
%keywordhash = map {$_ => 1} @keywords;
I guess you could also distinguish these two cases by noting that one calls map in void context whereas the other does not; while that's true, I think I'd still prefer
do {$keywordhash{$_}=(++$i);} for @keywords;
%keywordhash = map { $_ => ++$i } @keywords;
Even though I like map, because I'm not completely comfortable with the idea of depending on a certain execution order for map, even though I know it has one. When I'm thinking in a linear, this-gets-executed-then-this mode, map rarely makes sense. map does however make sense as a higher-order function, and when I'm thinking like that it's quite natural.

(Of course, all style niceties get completely discarded inside JAPHs)

@/=map{[/./g]}qw/.h_nJ Xapou cets krht ele_ r_ra/; map{y/X_/\n /;print}map{pop@$_}@/for@/

In reply to Re^2: Things I Don't Use in Perl by fizbin
in thread Things I Don't Use in Perl by Ovid

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2021-06-14 01:42 GMT
Find Nodes?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)

    Results (59 votes). Check out past polls.