Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

(jeffa) Re: Non-destructive array processing

by jeffa (Chancellor)
on Jan 21, 2003 at 02:43 UTC ( #228562=note: print w/ replies, xml ) Need Help??


in reply to Non-destructive array processing

I think the Perl 6 solution looks the best, but if i had to pick one of your original two, it would be the former. I think the predicate for the while loop looks, while the predicate for the for loop looks like C. I do love the way you copy the array, though ... that's sure to make some ears bleed. ;) But ... is there any benefit in doing so? Isn't my @r = @array; just as effective, or i am i missing a scalability issue here?

I have grown to dislike the C-style for(;;;) over the years, so much that i like to sometimes substitute a bit of speed for evilness such as:

my @array = 1..10; for my $i (grep $_%2, 0..$#array) { my @chunk = @array[$i - 1, $i]; print "Chunk: @chunk\n"; } print "Original array is still intact! (@array)\n";
However, my wise uncle would remind me that your second snippet is the best because it is simple and brute force. It has more potential to have a wider audience of programmers understand how it ticks then the first snippet does. I still like to make ears bleed, tho ... ;)

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)


Comment on (jeffa) Re: Non-destructive array processing
Download Code
Re: (jeffa) Re: Non-destructive array processing
by Juerd (Abbot) on Jan 21, 2003 at 19:40 UTC

    It has more potential to have a wider audience of programmers understand how it ticks then the first snippet does.

    Yeah :(

    Too bad the average Perl coder is stupid :(
    No offense...

    Juerd
    - http://juerd.nl/
    - spamcollector_perlmonks@juerd.nl (do not use).
    

      Too bad the average Perl coder is stupid :(

      Yeah, stupid people shouldn't be allowed on the Internet.

      In fact, they shouldn't be allowed to even program in Perl. Actually, why stop there? They shouldn't even be allowed to run Perl programs. Perl should just be for us 31337 h4x0rs. All these n00bs just hurt our image. I say we make Perl as hard as possible to use, that way these people won't even be able to figure it out. Fsck the maintenance programmers, they should be fired if they can't figure it out. Fsck people trying to learn from the code, if they can't figure it out they shouldn't be a programmer. I am great, everyone else is a fool.

      Software isn't about elitism, it's about empowering people. The more diverse and accessible the tools, the better off society will be. Programming languages can be designed to allow maximum usebility, both by the expert and by the novice. It neednt be a choice between marginalizing one group or the other. Perl is an excellent example of this, let's keep it that way.

      Peace :-)


      Reason: BrowserUk Delete: Inflammatory

      For more information on this node visit: this

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://228562]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (11)
As of 2014-07-24 20:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (167 votes), past polls