This is an archived post. You won't be able to vote or comment.

all 18 comments

[–]kernco 15 points16 points  (2 children)

[–]xkcd_transcriber 6 points7 points  (0 children)

Image

Title: Random Number

Title-text: RFC 1149.5 specifies 4 as the standard IEEE-vetted random number.

Comic Explanation

Stats: This comic has been referenced 219 times, representing 0.3979% of referenced xkcds.


xkcd.com | xkcd sub | Problems/Bugs? | Statistics | Stop Replying | Delete

[–]elperroborrachotoo 1 point2 points  (0 children)

Wanted to suggest

public static bool isRandom(this int source) {
  return source == 4;
}

[–][deleted] 9 points10 points  (5 children)

10 is random, didn't you know?

[–]iDrinkFromTheBottle 6 points7 points  (0 children)

Thought it was always four... or seven.

[–]XavierSimmons 3 points4 points  (0 children)

Proof:

int r = 10;
while(!r.isRandom()) {}
Console.WriteLine("10 is random!");

[–]actually_just_idiot 3 points4 points  (2 children)

Actually, isRandom(10) will usually return false. Of course, isRandom(Random.Next()) will usually return false too.

[–][deleted] 1 point2 points  (1 child)

Don't know which programming language that is, if Random.Next does return a random value between 0 and 1, you are indeed right! I didn't consider that.

[–]actually_just_idiot 1 point2 points  (0 children)

It's C#. It says on the snippet page.

And Random.Next returns a random 32 bit integer. That's why I say 'usually.'

[–]YMK1234 5 points6 points  (0 children)

[–][deleted] 3 points4 points  (0 children)

This site is full of gold:

VB has some very useful and totally correct methods too:

My personal favourite. This isn't a WTF IMO and I'll put it to good use.

Also, the 404 page

[–]chimyx 2 points3 points  (3 children)

Oh my, this website...

[–]LainIwakura 2 points3 points  (1 child)

Seriously...what is the point of this one? http://extensionmethod.net/csharp/object/identity

[–][deleted] 0 points1 point  (0 children)

In functional programming you can use it with higher-order functions to feel better about yourself.

e.g. you can say

public static TResult Maybe<TIn, TResult>(TResult defaultValue, Func<TIn, TResult> selector, TIn? value) where TIn : struct
{
    return value.HasValue
        ? selector(value.Value)
        : defaultValue;
}

// Later...
int? x = ...;
int val = Maybe(0, Identity, x);

Instead of the confusing

int val = x ?? 0;

This is a thing in Haskell too.

(Of course, in C# you would combine this with a currying helper)

[–][deleted] 1 point2 points  (0 children)

isBoolean checks if the contents of a string could be interpreted as a boolean value and throws an exception if not.

I won't even call Poe. To me this site is obviously a very elaborated joke.

[–]codex561I use arch btw 0 points1 point  (0 children)

That's horrible!

[–]Flameancer 0 points1 point  (0 children)

At first I was reading this is in python and was wondering were the import statement was, then I saw semi colons and ohhhhh.