?:
1
Name:
Anonymous
2010-11-27 11:12
How does /prog/ format their nested conditionals? I've been doing this:
foo ? bar :
baz ? quux :
quuux;
What do you find most attractive?
2
Name:
Anonymous
2010-11-27 11:14
[code] x ? y :
z ? w :
q;
3
Name:
Anonymous
2010-11-27 11:14
4
Name:
Anonymous
2010-11-27 11:19
hax
? my
: anus
? once
: more
5
Name:
Anonymous
2010-11-27 11:29
$a = ($cond == 1)
? 'hax'
: 'anus'
;
6
Name:
Anonymous
2010-11-27 11:30
...continued
$a = ($cond == 1)
? ($cond2 == 1)
? 'fag'
: 'hax'
: 'anus'
;
7
Name:
Anonymous
2010-11-27 11:41
"GRUNNUR" ? "GRUNNUR" :
"GRUNNUR" ? "GRUNNUR" :
*
"GRUNNUR"
;
8
Name:
Anonymous
2010-11-27 11:47
(cond
(foo bar)
(baz quux)
(t quuux))
9
Name:
Anonymous
2010-11-27 11:48
(code (foo bar)
(baz quux)
(else quuux))
10
Name:
Anonymous
2010-11-27 11:51
11
Name:
Anonymous
2010-11-27 11:51
>>4-6
How are those in any way readable?
12
Name:
Anonymous
2010-11-27 11:53
>>9
Obviously that was not the question.
13
Name:
Anonymous
2010-11-27 12:01
(hax < anus)? hax
: (hax > anus)? anus
: 0;
14
Name:
Anonymous
2010-11-27 12:09
>>12
Why would I ever use
(if foo? bar
(if baz? quux
quuux))
When I have
cond?
15
Name:
Anonymous
2010-11-27 12:33
>>13
OMG OPTIMIZED
(hax < anus)? hax
: (hax > anus)? anus
: "GRUNNUR";
16
Name:
Anonymous
2010-11-27 13:01
>>14
Obviously you wouldn't, but C sucks so you must. If you are in doubt about this thread's specificity to C and its imitators, please note the subject.
17
Name:
Anonymous
2010-11-27 13:04
(aBool) ? "Yes" :
(anInt > 0) ? "Yes" :
(anotherInt > 0 && anotherBool) ? "Yes" : "No";
Normally, I try to avoid nesting these things.
18
Name:
Anonymous
2010-11-27 13:10
>>17
I'd avoid nesting them too, if my formatting was as bad as yours.
19
Name:
Anonymous
2010-11-27 13:22
a?b:c?d:e?f:g;
20
Name:
Anonymous
2010-11-27 13:42
EXPERT TERNARY
!a? !b? !c? !d?
def(): d(): c(): b(): a();
!foo? !baz?
quuux: quux: bar;
!(hax < anus)? !(hax > anus)?
0: anus: hax;
21
Name:
Anonymous
2010-11-27 13:46
!a? !b? !c? !d?
def(): d(): c(): b(): a();
!foo? !baz?
quuux: quux: bar;
!(hax < anus)? !(hax > anus)?
0: anus: hax;
22
Name:
Anonymous
2010-11-27 14:01
>>20
I think I just
came a little in my mouth.
23
Name:
Anonymous
2010-11-27 15:56
anus = hurf() ? 0
: durf() ? 1
: herp() ? 2
: derp() ? 3
: 4;
Conditions in the first column, results in the second column.
24
Name:
Anonymous
2010-11-27 17:48
>>23
Hmm, interesting : placement.
25
Name:
Anonymous
2010-11-27 18:02
>>24
94% sure
>>23 is a Haskellite.
26
Name:
Anonymous
2010-11-27 18:16
27
Name:
Anonymous
2010-11-27 18:50
>>26
Yes, yes, we get it, you're a one-man army of retards. Now leave /prog/ forever.
28
Name:
Anonymous
2010-11-27 22:18
>>27
Fuck off,
66 homosexual99 .
29
Name:
Anonymous
2010-11-27 22:44
Ternary operator considered harmful
30
Name:
Anonymous
2010-11-28 1:41
``Considered harmful'' considered harmful
31
Name:
23
2010-11-28 3:28
>>25
I am. The idea for this comes from
Perl Best Practices though.
32
Name:
Anonymous
2010-11-28 3:40
>>14
(define-syntax ?
(syntax-rules (:)
((? e1 : r1 : r2)
(if e1 r1 r2))
((? e1 : r1 : r2 ...)
(if e1 r1 (r2 ...)))))
(? (= 1 2) : 1
: 2)
; => 2
(? (= 1 2) : 1 :
? (= 1 3) : 2 :
? (= 1 4) : 3 :
? (= 1 1) : 4 :
5)
; => 4
33
Name:
>>32
2010-11-28 3:41
34
Name:
Anonymous
2010-11-28 3:50
foo ? bar
: baz ? quux
: qox
Anything else is wrong.
35
Name:
Anonymous
2010-11-28 7:24
>>34
NESTED CONDITIONALS
as if else if never existed
36
Name:
Anonymous
2010-11-28 9:18
>>35
DEMOTIVATIONALS
now you can Go back to /b/, please.
37
Name:
Anonymous
2010-11-28 9:27
>>36
I wasn't even thinking that. You appear to have a guilty conscience.
38
Name:
Anonymous
2010-11-28 10:09
>>37
WHO,
ME‽ .
HA
HAHAHAHA ,
NO .
39
Name:
Anonymous
2010-11-28 11:23
>>36
Your a fucking faggot and you should kill you're self
40
Name:
Anonymous
2010-11-28 11:28
41
Name:
Anonymous
2010-11-28 11:47
66 faggots99 66 niggers 99[/sub] [/sub]
42
Name:
Anonymous
2010-11-28 11:51
>>34
How do you live with increasing indentation for each step of what is essentially a
linear structure ?
43
Name:
Anonymous
2010-11-28 12:00
44
Name:
Anonymous
2010-11-28 15:02
>>36-41,43
Personally I'm glad each of you are here, because god help us if this board was actually worth reading.
Also
>>20,21 cute...
!if1 ? !if2 ? !if3 ? !if4 ?
wasnone : was4: was3: was2: was1;
45
Name:
Anonymous
2010-11-29 4:30
>>35
!if ?NESTED CONDITIONALS
[code] : else if;
46
Name:
Anonymous
2010-11-29 4:31
>>45
!if ?NESTED CONDITIONALS
: else if;
BB CODE ``faggotry'' !
48
Name:
Anonymous
2011-02-04 19:26