Fastest Way to...

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

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.

What's the fastest way to do this? Right now I'm using

    if pos[1] > 0 then
       pos[1] = 1
    end if
    if pos[2] > 0 then
       pos[2] = 1
    end if
    if pos[3] > 0 then
       pos[3] = 1
    end if

I have a feeling this is fastest. Will it be as fast if put in a loop 
for arbitrary length?

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

Search



Quick Links

User menu

Not signed in.

Misc Menu