Fastest Way to...
- Posted by euphoriCK <euphoric at cklester.com> Oct 28, 2003
- 392 views
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?