Re: Fastest Way to...
- Posted by Pete Lomax <petelomax at blueyonder.co.uk> Oct 28, 2003
- 390 views
On Mon, 27 Oct 2003 21:09:04 -0600, "C. K. Lester" <euphoric at cklester.com> wrote: > > >C. K. Lester wrote: > >> I've got a 3-element sequence... >> >> { 3, -1, 0 } >> >> and need to turn it into this >> >> { 1, -1, 0 } >> >> That is, any positive values ( > 0 ) should be turned to one. > > >Okay, here's my attempt: > >junk =3D pos <=3D 0 >pos =3D pos * junk >pos +=3D not junk > >Yes, I know I could combine that into some big convoluted function, but= =20 >you get the gist. That's about 3=BD times slower. In your first post, you "unrolled the loop" which is a classic way to make something as fast as possible. Pete