Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^2: array splitting

by CColin (Scribe)
on Jun 05, 2007 at 11:49 UTC ( #619358=note: print w/replies, xml ) Need Help??


in reply to Re: array splitting
in thread array splitting

>(5,6,7,8,9,10, 15, 20...)
That can't happen - See the condition above in that no neighbour (ie. next adjacent number) is ever less than 5, and also all sequences are always ascending. Hence there should be a solution for this type of final data. Here is some code that sorts the first list so that all distances between numbers in the first list 10 or more, but fails for the second list when 2 or more consecutive numbers are less than 10.
$count = 0; $time = 0; $last_time = 0; $time_diff = 100; #to ensure the first value appears in list 1 foreach $time (@times) { unless ($count == 0) {$time_diff = $last_time - $time}; if ($time_diff >= 10) {push (@times1, $time} else {push (@times2, $time)}; $last_time = $time; $count ++; } #end foreach

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://619358]
help
Chatterbox?
[Discipulus]: good morning nuns and monks!
[marioroy]: Morning Discipulus. porting C code to Perl is an interesting problem for running parallel. I will try and the reason for attempting Perl code to match C 100%.

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (9)
As of 2017-10-24 07:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My fridge is mostly full of:

















    Results (286 votes). Check out past polls.

    Notices?