Re: Fastest Way to...

new topic     » goto parent     » topic index » view thread      » older message » newer message

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

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu