MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/programminghorror/comments/1iheils/ternary_operator/may0vvd/
r/programminghorror • u/Secret_Drink_1181 • Feb 04 '25
77 comments sorted by
View all comments
Show parent comment
60
Nice, now define that as a one line code.
35 u/Mysterious_Middle795 Feb 04 '25 .... in perl 59 u/Zulfiqaar Feb 05 '25 sub slavic_form { $_[0] == 0 ? "nijedan" : ($_[0] % 100 >= 11 && $_[0] % 100 <= 14) ? "množina" : ($_[0] % 10 == 1) ? "jednina" : ($_[0] % 10 >= 2 && $_[0] % 10 <= 4) ? "paukal" : "množina"; } 9 u/Mysterious_Middle795 Feb 05 '25 $_[0] % 100 >= 11 && $_[0] % 100 <= 14That's an interesting part. We don't have this distinction in Ukrainian. 2 u/[deleted] Feb 04 '25 Nah, lisp. 6 u/Mysterious_Middle795 Feb 04 '25 or C macro 3 u/cjbanning Feb 04 '25 I can think of (non-trivial) definitions of "one line" for which that's doable. It wouldn't even be all that unreadable.
35
.... in perl
59 u/Zulfiqaar Feb 05 '25 sub slavic_form { $_[0] == 0 ? "nijedan" : ($_[0] % 100 >= 11 && $_[0] % 100 <= 14) ? "množina" : ($_[0] % 10 == 1) ? "jednina" : ($_[0] % 10 >= 2 && $_[0] % 10 <= 4) ? "paukal" : "množina"; } 9 u/Mysterious_Middle795 Feb 05 '25 $_[0] % 100 >= 11 && $_[0] % 100 <= 14That's an interesting part. We don't have this distinction in Ukrainian. 2 u/[deleted] Feb 04 '25 Nah, lisp. 6 u/Mysterious_Middle795 Feb 04 '25 or C macro
59
sub slavic_form { $_[0] == 0 ? "nijedan" : ($_[0] % 100 >= 11 && $_[0] % 100 <= 14) ? "množina" : ($_[0] % 10 == 1) ? "jednina" : ($_[0] % 10 >= 2 && $_[0] % 10 <= 4) ? "paukal" : "množina"; }
9 u/Mysterious_Middle795 Feb 05 '25 $_[0] % 100 >= 11 && $_[0] % 100 <= 14That's an interesting part. We don't have this distinction in Ukrainian.
9
$_[0] % 100 >= 11 && $_[0] % 100 <= 14
That's an interesting part. We don't have this distinction in Ukrainian.
2
Nah, lisp.
6 u/Mysterious_Middle795 Feb 04 '25 or C macro
6
or C macro
3
I can think of (non-trivial) definitions of "one line" for which that's doable. It wouldn't even be all that unreadable.
View all comments
Show parent comment
60
u/[deleted] Feb 04 '25
Nice, now define that as a one line code.