in reply to Re^2: Random partitions? (Thanks and solution.)
in thread Random partitions?

That'd work, but basically means duplicating the loop logic. (In part or in full.)

Update: Cleaner second loop.

But as I've already changed the routine to produce an array and return a ref to it -- 3 intermediates lists gets costly once count get over a few hundred -- tossing the coin afterward and reverseing and 'inverting' the values is a bit easier:

sub rndPart3{ ## strictly ascending, skew possible my( $start, $end, $count ) = @_; my $step = ( $end - $start ) / $count; my $last = $start; $start += $step / 2; my @res; my $lim = $count - 1; for( my( $i, $p ) = ( 0, $start); $i < $lim; ++$i, $p += $step ) { push @res, sprintf "%.2f", $last = $last + ( rand( $p + $step/ +2 - $last ) ); } if( rand() < 0.5 ) { for( my( $s, $e ) = ( 0, $#_ ); $s <= $e; ++$s, --$e ) { my $temp = $end - $_[ $s ]; $_[ $s ] = $end - $_[ $e ]; $_[ $e ] = $temp; } } return \@res; }

Not very pleasing though!?


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority". I'm with torvalds on this
In the absence of evidence, opinion is indistinguishable from prejudice. Agile (and TDD) debunked