Alternating sign function (f0=1, f1=-1, f2=1, f3=-1, …) -> ((x % 2) * -1 + ((x + 1) % 2)) Can anyone improve on this? Seems clunky
@axis12345678 "-1 ^ (x % 2)" - or maybe a ternary "(x % 2) ? -1 : 1" ?
-
-
@calvinfo cool idea, but I modified it to (-1 ^ (x % 2) * 2 + 3…at least for the ruby implementation I'm using. not sure if it's betterThanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
@calvinfo ternary uses branching so should be slower than straight integer mathThanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.