Programming Megathread

Author Topic: Programming Megathread  (Read 106216 times)

in other news, wtf

using System;

namespace Program {
  class Program {
    static void Main(String[] args) {
      Console.WriteLine(String.Join(" ", args[0].Split(',').Reverse()));
    }
  }
}


error



using System;
using System.Linq;

namespace Program {
  class Program {
    static void Main(String[] args) {
      Console.WriteLine(String.Join(" ", args[0].Split(',').Reverse()));
    }
  }
}


no error

apparently System.Linq extends the Array class somehow or something. but what if I don't wanna have a using directive? then wtf do I do to get the same functionality
why.......

According the MSDN, there are multiple versions of Reverse(); the one that uses Linq is this one:

Enumerable

But there are two other variants:

Arrays
Lists

I am particularly curious as to why args[0].Split(','), which should return a standard character array, is trying to use the Enumerable variant.

well,
uh
Array and List don't have Reverse method overrides that take no arguments, so error. IEnumerable's Reverse does, so no error. I don't have any trouble with that, the problem I am having is just with using it, without using using. idk how System.Linq achieves adding those overrides but honestly I don't really care, because I'm never going to try something quite that stupid
presumably Array and List both implement IEnumerable so the method works with the return values there regardless

torquescript is weird
so you guys know about Quines?
Well, with an extremely weird little quirk of Torque, making a quine is very easy. 40 characters easy.

%a="aaaaaaaaaa";%a=%a@%a@%a@%a;echo(*0);

If you put that in the console, it'll output that code. If you replace echo with eval, it'll just outright stop responding because it gets stuck in an infinite loop. I have no idea why it works either.

torquescript is weird
so you guys know about Quines?
Well, with an extremely weird little quirk of Torque, making a quine is very easy. 40 characters easy.

%a="aaaaaaaaaa";%a=%a@%a@%a@%a;echo(*0);

If you put that in the console, it'll output that code. If you replace echo with eval, it'll just outright stop responding because it gets stuck in an infinite loop. I have no idea why it works either.
whaaaaaaaaaaaaaaaaaa

apparently System.Linq extends the Array class somehow or something
.NET has what's called extension methods
There's multiple other examples

but what if I don't wanna have a using directive? then wtf do I do to get the same functionality
why.......
Well if you really wanted to you could rewrite the extension method from within your own code
But I really don't see why it's an issue. It's just a single line that you're not really going to pay much attention too


also i don't think not responding at all implies any sort of answer, even a "no"
If you ask a single person a question in a one-on-one conversation, and they don't answer, then you can conclude they didn't hear you or are are ignoring you.
But that doesn't work in an online forum with potentially hundreds of participants.
« Last Edit: September 17, 2016, 10:18:31 AM by Headcrab Zombie »


Created handy structs to define parameterized (template) points and lines in C++.

Points have an x and a y, and the overloaded operators simply add/subtract/multiply/divide two point operators together.

Lines have two points like you'd expect, but their overloaded operators are slightly more involved. Adding and subtracting is a translation that uses the source line's displacement as a point, and multiplying and dividing is a dilation using the source line's length.

Bigass pastebin

okay wtf I just got 20 keybase invites
hmu if you want one

okay wtf I just got 20 keybase invites
hmu if you want one
And I still have 15 of them...

Spent five hours coding something and lost it all through system recovery. :D
Best part is that it's already been overwritten by the data recovery software I downloaded!!

I would like a keybase invite


f how am I going to finish giving out my 20 invites if every person I give an invite to gets 20 invites

keybase is a trap


Spent five hours coding something and lost it all through system recovery. :D
Best part is that it's already been overwritten by the data recovery software I downloaded!!
Time to invest in version control!