in reply to Re: Better mousetrap (getting top N values from list X)
in thread Better mousetrap (getting top N values from list X)
or would you prefer:my @top26 = my($a, $b, $c, $d, $e, $f, $g, $h, $i, $j, $k, $l, $m, $n, + $o, $p, $q, $r, $s, $t, $u, $v, $w, $x, $y, $z) = sort @foo
I'm willing to use up to three variables - but if I only want to extract the top3, I could easily write a single pass algorithm, keeping track of the top3.my @top26 = top (26, @foo);
And you'd need to write tricky evals if you don't know which top N to take during compile time, but only at run time (for instance, because N is user input).
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Better mousetrap (getting top N values from list X)
by BrowserUk (Patriarch) on Feb 03, 2005 at 10:33 UTC | |
by tall_man (Parson) on Feb 03, 2005 at 18:36 UTC | |
by BrowserUk (Patriarch) on Feb 03, 2005 at 22:17 UTC | |
by tall_man (Parson) on Feb 04, 2005 at 00:54 UTC | |
by BrowserUk (Patriarch) on Feb 04, 2005 at 01:11 UTC | |
|