Standard Forth versus Python: a case study
B M
idknow at gmail.com
Fri Oct 13 17:39:13 EDT 2006
i hang my head in shame.
On 10/12/06, Gabriel Genellina <gagsl-py at yahoo.com.ar> wrote:
> At Thursday 12/10/2006 17:44, idknow at gmail.com wrote:
>
> > > > > fun median {
> > > > > var x = 0.
> > > > > while( *p++) {
> > > > > if( (*p) > x) x = *p.
> > > > > }
> > > > > return x.
> > > > > }
> >
> >clearly, i've forgotten the definition of the median of a list.
> >to that i plead faulty memory.
>
> That explains all. Finding the median in an efficient way (that is,
> without sorting the data first) isn't trivial, so your claim of "I
> can do that using only one temp variable" was a bit surprising...
> BTW, the median is the value which sits just in the middle of the
> list when ordered: median(3,5,12,1,2)=median(1,2,3,5,12) = 3
>
>
> --
> Gabriel Genellina
> Softlab SRL
>
>
>
>
>
> __________________________________________________
> Preguntá. Respondé. Descubrí.
> Todo lo que querías saber, y lo que ni imaginabas,
> está en Yahoo! Respuestas (Beta).
> ¡Probalo ya!
> http://www.yahoo.com.ar/respuestas
>
>
>
More information about the Python-list
mailing list