Re: Fastest Way to...

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

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 = pos <= 0
pos = pos * junk
pos += not junk

Yes, I know I could combine that into some big convoluted function, but 
you get the gist.

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

Search



Quick Links

User menu

Not signed in.

Misc Menu