Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Hey People,

As usual leons and I were coding a bit, and tried
to find a way to mix n number of m lenght arrays
together, preserving the original order of the
original arrays

I came up with this:
#!/usr/bin/perl -w use strict; sub Mix; my @Row1=(1,3,5,7); my @Row2=(2,4,6); my @Row3=(9,9,9); my @Row4=Mix(\@Row1,\@Row2,\@Row3); print "@Row4\n"; sub Mix { my @Result; while(1) { my $Old=@Result; push @Result,grep $_,shift @{$_} for @_; last if @Result==$Old; }; @Result; };
Output: 1 2 9 3 4 9 5 6 9 7

Anyway to do it quicker/more efficient/shorter ?


GreetZ!,
    ChOas

print "profeth still\n" if /bird|devil/;

In reply to Mixing up da Arrays (Golf) by ChOas

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    [Tanktalus]: Sure, no one is active for hours and hours in the cb, so I go to upgrade the db, and then someone is active. Sheesh :)
    [Discipulus]: anyway poppins probably died with the last night cold. But is not normal to see them in dec. they must pop in April
    NodeReaper eyes the thorns in the side
    Discipulus : the party puller!
    [Discipulus]: I was trying to solve this but i'm not. my regex-fu is stuck at primary school

    How do I use this? | Other CB clients
    Other Users?
    Others about the Monastery: (6)
    As of 2017-12-18 21:39 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      What programming language do you hate the most?




















      Results (499 votes). Check out past polls.

      Notices?