in reply to Re^7: Date Array Convolution
in thread Date Array Convolution
The only difference between our solutions now is that my solution merges neighbouring intervals
Understood. It was a concious decision not to concatenate adjacent intervals even if there values are the same, if they derived from different input intervals.
As I mentioned in my post, I build two parallel arrays. One contains the lowest values used for each minute. The other the index of the source interval that contributed that value. In the event that two different source intervals with the same value abut, then I can have data like this:
value: 22222111111111111 44444 source: 33333555599999999 77777
I can either walk the source array and pick out 4 intervals -- this is what I posted above -- or I can walk the value array and pick out 3 intervals.
The change is trivial. This
my @res; my $i = 0; while( $i < $#id ) { ++$i until defined $id[ $i ]; my $id = $id[ $i ]; my $start = $i; ++$i while defined( $id[ $i ] ) and $id[ $i ] == $id; my $end = $i - 1; push @res, [ int2dhm( $start ), int2dhm( $end ), $tally[ $start ] +]; }
Becomes this:
my @res; my $i = 0; while( $i < $#tally ) { ++$i until defined $tally[ $i ]; my $val = $tally[ $i ]; my $start = $i; ++$i while defined( $tally[ $i ] ) and $tally[ $i ] == $val; my $end = $i - 1; push @res, [ int2dhm( $start ), int2dhm( $end ), $val ]; }
It wasn't clear to me from the OP which was expected. I was expecting feedback fro the OP but it never came.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^9: Date Array Convolution
by choroba (Cardinal) on Nov 08, 2011 at 06:43 UTC | |
by BrowserUk (Patriarch) on Nov 08, 2011 at 17:01 UTC | |
by choroba (Cardinal) on Nov 08, 2011 at 23:06 UTC | |
by BrowserUk (Patriarch) on Nov 09, 2011 at 00:12 UTC | |
by choroba (Cardinal) on Nov 09, 2011 at 10:22 UTC | |
| |
by alanonymous (Sexton) on Nov 08, 2011 at 16:12 UTC |