Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-4041-

?:

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?

Name: Anonymous 2010-11-27 11:14

[code]x ? y :
z ? w :
q;

Name: Anonymous 2010-11-27 11:14

>>2
[/code]

Name: Anonymous 2010-11-27 11:19


hax
? my
: anus
? once
: more

Name: Anonymous 2010-11-27 11:29


$a = ($cond == 1)
  ? 'hax'
  : 'anus'
;

Name: Anonymous 2010-11-27 11:30

...continued


$a = ($cond == 1)
  ? ($cond2 == 1)
    ? 'fag'
    : 'hax'
  : 'anus'
;

Name: Anonymous 2010-11-27 11:41

"GRUNNUR" ? "GRUNNUR" :
"GRUNNUR" ? "GRUNNUR" :
*
"GRUNNUR"
;

Name: Anonymous 2010-11-27 11:47

(cond
  (foo bar)
  (baz quux)
  (t quuux))

Name: Anonymous 2010-11-27 11:48


(code (foo bar)
      (baz quux)
      (else quuux))

Name: Anonymous 2010-11-27 11:51

>>9
I mean (cond

Name: Anonymous 2010-11-27 11:51

>>4-6
How are those in any way readable?

Name: Anonymous 2010-11-27 11:53

>>9
Obviously that was not the question.

Name: Anonymous 2010-11-27 12:01

(hax < anus)? hax
    : (hax > anus)? anus
    : 0;

Name: Anonymous 2010-11-27 12:09

>>12
Why would I ever use

(if foo? bar
         (if baz? quux
                  quuux))


When I have cond?

Name: Anonymous 2010-11-27 12:33

>>13
OMG OPTIMIZED

(hax < anus)? hax
    : (hax > anus)? anus
    : "GRUNNUR";

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.

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.

Name: Anonymous 2010-11-27 13:10

>>17
I'd avoid nesting them too, if my formatting was as bad as yours.

Name: Anonymous 2010-11-27 13:22

a?b:c?d:e?f:g;

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;

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;

Name: Anonymous 2010-11-27 14:01

>>20
I think I just came a little in my mouth.

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.

Name: Anonymous 2010-11-27 17:48

>>23
Hmm, interesting : placement.

Name: Anonymous 2010-11-27 18:02

>>24
94% sure >>23 is a Haskellite.

Name: Anonymous 2010-11-27 18:16

>>25
U MENA HASKALIAN?

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.

Name: Anonymous 2010-11-27 22:18

>>27
Fuck off, 66homosexual99.

Name: Anonymous 2010-11-27 22:44

Ternary operator considered harmful

Name: Anonymous 2010-11-28 1:41

``Considered harmful'' considered harmful

Name: 23 2010-11-28 3:28

>>25

I am. The idea for this comes from Perl Best Practices though.

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

Name: >>32 2010-11-28 3:41

s/>>14/>>16/

Name: Anonymous 2010-11-28 3:50

foo ? bar
    : baz ? quux
          : qox


Anything else is wrong.

Name: Anonymous 2010-11-28 7:24

>>34
NESTED CONDITIONALS
as if else if never existed

Name: Anonymous 2010-11-28 9:18

>>35
DEMOTIVATIONALS
now you can Go back to /b/, please.

Name: Anonymous 2010-11-28 9:27

>>36
I wasn't even thinking that. You appear to have a guilty conscience.

Name: Anonymous 2010-11-28 10:09

>>37
WHO, ME.
HAHAHAHAHA, NO.

Name: Anonymous 2010-11-28 11:23

>>36
Your a fucking faggot and you should kill you're self

Name: Anonymous 2010-11-28 11:28

>>39
back to /b/

Name: Anonymous 2010-11-28 11:47

66faggots99 66niggers99[/sub][/sub]

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?

Name: Anonymous 2010-11-28 12:00

>>40
eat shit and die

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;

Name: Anonymous 2010-11-29 4:30

>>35
  !if ?NESTED CONDITIONALS
[code]:       else if;

Name: Anonymous 2010-11-29 4:31

>>45
  !if ?NESTED CONDITIONALS
:       else if;

BB CODE ``faggotry''!

Name: Anonymous 2011-02-04 19:26

Don't change these.
Name: Email:
Entire Thread Thread List