Beefy Boxes and Bandwidth Generously Provided by pair Networks Frank
more useful options
 
PerlMonks  

Re: New student, can we write this program in perl...

by aaron_baugher (Deacon)
on Oct 19, 2012 at 19:47 UTC ( #1000027=note: print w/ replies, xml ) Need Help??


in reply to New student, can we write this program in perl...

See if your "teacher" likes this method:

#!/usr/bin/env perl use Modern::Perl; my @n = (1..100); my @e; my @o; map { push @{($_ % 2 ? \@o : \@e)}, $_ } @n; say for @e;

Here's another:

#!/usr/bin/env perl use Modern::Perl; my @n = (1..100); my @o = sort { $a % 2 - $b % 2 } @n; my @e = splice @o, 0, @o/2, (); say for @e;

Aaron B.
Available for small or large Perl jobs; see my home node.


Comment on Re: New student, can we write this program in perl...
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (10)
As of 2014-04-20 19:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (486 votes), past polls