Timeline for Tips for golfing in C
Current License: CC BY-SA 3.0
6 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Apr 9, 2019 at 4:56 | comment | added | Chris Uzdavinis | both clang and gcc allow for an empty true case in the ternary. If omitted, its value is the value of the condition. For example, x>5?:y=1 | |
| Feb 20, 2015 at 2:43 | history | wiki removed | Doorknob | ||
| May 8, 2012 at 10:44 | comment | added | ugoren | Another point is that sometimes you want to flip the condition: for x>0||(y=3), x>0?0:(y=3) is useless, but x<1?y=3:0 does the job. | |
| May 8, 2012 at 8:54 | comment | added | breadbox | Good point; my example was needlessly complex. | |
| May 8, 2012 at 7:30 | comment | added | ugoren | In this example, b-=a=b is even shorter. The ?: trick is still helpful, -= because also has low preference. | |
| May 7, 2012 at 2:35 | history | answered | breadbox | CC BY-SA 3.0 |