KermMartian wrote:
I could totally see a case where you split a ternary containing a bunch of sub and sub-sub ternaries across several lines, and it would be considered both a good idea to use a ternary and to do the split. Razz


No it wouldn't. It would be a bad idea through and through. Nested ternaries are wrong to begin with, even just a single nested ternary is flat out wrong. If you're need to do something like that in Python, you suck as a programmer. And if it isn't in Python, google "switch statement".

BrandonW wrote:
Kllrnohj wrote:
You're point WAS that you can break...


Off-topic, but shame.


Seriously? Why does everyone feel the need to point out the single grammar mistake in my 100+ word posts? Have you looked around at the crap others post? Omg! Kllrnohj had a *single* minor mistake in his post! Quick, point it out! Rolling Eyes

Hell, if the rest of you only made such minor mistakes I'd die from shock.
Kllrnohj wrote:
Seriously? Why does everyone feel the need to point out the single grammar mistake in my 100+ word posts? Have you looked around at the crap others post? Omg! Kllrnohj had a *single* minor mistake in his post! Quick, point it out! Rolling Eyes
Because you're always such a stickler pointing out such things in other people's posts, people try to hold you to a very high standard in return. Smile
KermMartian wrote:
Kllrnohj wrote:
Seriously? Why does everyone feel the need to point out the single grammar mistake in my 100+ word posts? Have you looked around at the crap others post? Omg! Kllrnohj had a *single* minor mistake in his post! Quick, point it out! Rolling Eyes
Because you're always such a stickler pointing out such things in other people's posts, people try to hold you to a very high standard in return. Smile

I don't have anything else to say, so I'll just try to replicate whatever the default QFT filter says in situations like this where I have nothing to add.
KermMartian wrote:
I could totally see a case where you split a ternary containing a bunch of sub and sub-sub ternaries across several lines, and it would be considered both a good idea to use a ternary and to do the split. Razz



Code:
 public static int width(IntBST t) {
      return (t == null) ? 0 :
            (t.isLeaf() ? 2 :
               ((t.left() == null && t.right != null) ? 1 + width(t.right()) :
                  ((t.left() != null && t.right == null) ? 1 + width(t.left()) :
                     width(t.left()) + width(t.right())
                  )
               )
            );
    }
elfprince13 wrote:



Code:
 public static int width(IntBST t) {
      return (t == null) ? 0 :
            (t.isLeaf() ? 2 :
               ((t.left() == null && t.right != null) ? 1 + width(t.right()) :
                  ((t.left() != null && t.right == null) ? 1 + width(t.left()) :
                     width(t.left()) + width(t.right())
                  )
               )
            );
    }


I feel like you've posted this as your facebook status before...
elfprince13 wrote:
KermMartian wrote:
I could totally see a case where you split a ternary containing a bunch of sub and sub-sub ternaries across several lines, and it would be considered both a good idea to use a ternary and to do the split. Razz



Code:
 public static int width(IntBST t) {
      return (t == null) ? 0 :
            (t.isLeaf() ? 2 :
               ((t.left() == null && t.right != null) ? 1 + width(t.right()) :
                  ((t.left() != null && t.right == null) ? 1 + width(t.left()) :
                     width(t.left()) + width(t.right())
                  )
               )
            );
    }
Exactly! This is a perfect example of nested ternaries used clearly and concisely.
elfprince13 wrote:

Code:
 public static int width(IntBST t) {
      return (t == null) ? 0 :
            (t.isLeaf() ? 2 :
               ((t.left() == null && t.right != null) ? 1 + width(t.right()) :
                  ((t.left() != null && t.right == null) ? 1 + width(t.left()) :
                     width(t.left()) + width(t.right())
                  )
               )
            );
    }
That's hott Shock


BrandonW wrote:
Kllrnohj wrote:
You're point WAS that you can break...


Off-topic, but shame.
"You are point was that you can break..."? Correct me if I'm wrong, but I was under the impression he was correct in the beginning. It was, in fact, MY point that he was referring to? Read it again. "Your" is the possessive pronoun form of "You". "You're" is contracted "You Are".
He edited it. It was first "you're" and then Brandon pointed it out, and then he changed it to "your" without note, making it look like Brandon is dumb. You can see that Brandon posted on "11 Jul 2010 10:56:57 pm" and the last edit of Kllrnohj's post is "12 Jul 2010 12:55:40 am".
Poor Brandon.
KermMartian wrote:
Because you're always such a stickler pointing out such things in other people's posts, people try to hold you to a very high standard in return. Smile


[Citation Needed]

Seriously, I only point out people's crappy grammar when they only manage to get a single word correct, not when they manage to only get a single word wrong. Completely opposite end of the spectrum.

KermMartian wrote:
elfprince13 wrote:
KermMartian wrote:
I could totally see a case where you split a ternary containing a bunch of sub and sub-sub ternaries across several lines, and it would be considered both a good idea to use a ternary and to do the split. Razz



Code:
 public static int width(IntBST t) {
      return (t == null) ? 0 :
            (t.isLeaf() ? 2 :
               ((t.left() == null && t.right != null) ? 1 + width(t.right()) :
                  ((t.left() != null && t.right == null) ? 1 + width(t.left()) :
                     width(t.left()) + width(t.right())
                  )
               )
            );
    }
Exactly! This is a perfect example of nested ternaries used clearly and concisely.


Actually that would be the perfect example of a *bad* use of ternaries. It's not readable and it's slower than if you removed the ternaries thanks to duplicate function calls that a compiler can't optimize.
Kllrnohj wrote:
KermMartian wrote:
Exactly! This is a perfect example of nested ternaries used clearly and concisely.


Actually that would be the perfect example of a *bad* use of ternaries. It's not readable and it's slower than if you removed the ternaries thanks to duplicate function calls that a compiler can't optimize.
Citation needed yourself! Based on implementing my own compiler, where a ternary almost precisely got converted to a conditional If/Else scope in the AST, there's nothing that should prevent optimization of those duplicated function calls. Where are you pulling this from?
KermMartian wrote:
Citation needed yourself! Based on implementing my own compiler, where a ternary almost precisely got converted to a conditional If/Else scope in the AST, there's nothing that should prevent optimization of those duplicated function calls. Where are you pulling this from?


You can't optimize away duplicate function calls or the code won't work. In the snippet Elf posted, right() will be invoked up to 3 times depending on the various values. Had it instead be written properly and not used a disgusting mess of nested crap, right() need only be invoked a single time for all cases (same for left())
foamy3 wrote:
elfprince13 wrote:



Code:
 public static int width(IntBST t) {
      return (t == null) ? 0 :
            (t.isLeaf() ? 2 :
               ((t.left() == null && t.right != null) ? 1 + width(t.right()) :
                  ((t.left() != null && t.right == null) ? 1 + width(t.left()) :
                     width(t.left()) + width(t.right())
                  )
               )
            );
    }


I feel like you've posted this as your facebook status before...

Yes. I have.


Kllrnohj: we were required to use functional programming styles for this assignment. That code would translate incredibly easily into LISP or Scheme.
elfprince13 wrote:
Kllrnohj: we were required to use functional programming styles for this assignment. That code would translate incredibly easily into LISP or Scheme.
Yes, but in functional programming languages you typically have the advantage of being able to avoid side-effects allowing you to make such optimisations easily.
elfprince13 wrote:
we were required to use functional programming styles for this assignment. That code would translate incredibly easily into LISP or Scheme.

Why wasn't it just written in a functional language, then? That seems like a silly thing to me Smile.

Speaking of ternaries, I came across this today:

Code:
return (url.Contains("?")
    ? String.Concat(url, "&startdate=", startTime, ...)
    : String.Concat(url, "?startdate=", startTime, ...)
    );

And the stuff that the ellipses are representing was exactly the same.

It was kind of neat to see a line of C# code starting with a question mark.

And for fun:

Code:
#define sizeof(x) rand()
merthsoft wrote:
elfprince13 wrote:
we were required to use functional programming styles for this assignment. That code would translate incredibly easily into LISP or Scheme.

Why wasn't it just written in a functional language, then? That seems like a silly thing to me Smile.


Because unless you go to MIT, which has a Scheme complex, everyone teaches data structures in Java or C++.
elfprince13 wrote:
Because unless you go to MIT, which has a Scheme complex, everyone teaches data structures in Java or C++.


And why were you told to use function programming styles for an assignment not in a functional language?

'Cause that's a retarded assignment full of fail and promoting horrible, horrible coding style.
Kllrnohj wrote:
elfprince13 wrote:
Because unless you go to MIT, which has a Scheme complex, everyone teaches data structures in Java or C++.


And why were you told to use function programming styles for an assignment not in a functional language?

'Cause that's a retarded assignment full of fail and promoting horrible, horrible coding style.

because the classroom is not a production environment, Data Structures students haven't taken Programming Languages yet, and because learning to think in a functional style is more important than what language you do it in.

But for the record, Java is fully capable of being a functional language.
Oh God. I can only assume this is going to start another pointless debate. So before that happens let me sum it up:
Java sux lol
No is gr8
No is sux
No is gr8
No is sux
[citation needed]
No u
Fail

Ok, now that that's done, how about some silly programming things?
merthsoft wrote:
Oh God. I can only assume this is going to start another pointless debate. So before that happens let me sum it up:
Java sux 0x5
No is gr8
No is sux
No is gr8
No is sux
[citation needed]
No u
Fail

Ok, now that that's done, how about some silly programming things?
Good Idea Laughing
elfprince13 wrote:
But for the record, Java is fully capable of being a functional language.


Just what we needed!

Oh, wait, no. That isn't being a functional language, that is over-engineering well past the point of being retarded

And that is only two functional techniques - a far cry from being a functional language.

Also, all the casts to/from Object just highlights that Java really can't handle it in the first place.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
» Goto page Previous  1, 2, 3, 4, 5, 6  Next
» View previous topic :: View next topic  
Page 3 of 6
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement