Standard Forth versus Python: a case study
idknow at gmail.com
idknow at gmail.com
Thu Oct 12 07:32:02 EDT 2006
Paul McGuire wrote:
> <idknow at gmail.com> wrote in message
> news:1160619958.438049.53390 at h48g2000cwc.googlegroups.com...
> > [snip]
> >
> > no sort() is needed to calculate the median of a list.
> >
> > you just need one temp var.
> >
>
> Ok, I'll bite. How do you compute the median of a list using just a single
> temp var?
>
> -- Paul
hi Paul; well when this was a stats-class assignment (back when pascal
was popular :) i just stepped through the vector and compared it
(pseudo-code)
ptr p = [with values].
fun median {
var x = 0.
while( *p++) {
if( (*p) > x) x = *p.
}
return x.
}
of course, pascal is more verbose but that's median()
More information about the Python-list
mailing list