Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

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

by aaron_baugher (Curate)
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 scrutinizing the Monastery: (10)
As of 2015-07-02 06:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (29 votes), past polls