The Student Room Group
Learning at Imperial College London
Imperial College London
London

Scroll to see replies

:pirate:
Learning at Imperial College London
Imperial College London
London
Reply 2
lol haha, i was just going through that common pitfalls pdf.... :smile: the dreaded O(n^2) complexity!
Reply 3
lmao @ infinite recursion...
Reply 4
Maybe many of you don't understand why is it funny.

It is even sadder.
taniubi
Maybe many of you don't understand why is it funny.

It is even sadder.


What's even sadder is that you didn't write what lang/syntax it is. That line isn't valid syntax in any language I've used so far.

Is f xs supposed to mean something? f of xs? Is this imperative or declarative?

Clarification is needed
Reply 6
DavidR1991
What's even sadder is that you didn't write what lang/syntax it is. That line isn't valid syntax in any language I've used so far.

Is f xs supposed to mean something? f of xs? Is this imperative or declarative?

Clarification is needed


As far as I can tell, it's vaguely something like this (where var is a number type):

var f(var xs)
{
if(xs == NULL) return 0;
return 1 + f(xs);
}
Im gonna get outta here before I read anything I didn't need to.
Reply 8
f is the function that computes the length of a list

f xs = if length xs == 0 then 0 else 1 + f xs

Forget about the infinite loop, though it is one.

Does it look a little bit funny to you now?
Reply 9
DavidR1991
What's even sadder is that you didn't write what lang/syntax it is. That line isn't valid syntax in any language I've used so far.

Is f xs supposed to mean something? f of xs? Is this imperative or declarative?

Clarification is needed


Clarification: It's Haskell
Reply 10
taniubi
f is the function that computes the length of a list

f xs = if length xs == 0 then 0 else 1 + f xs

Forget about the infinite loop, though it is one.

Does it look a little bit funny to you now?


I have no clue what's going on.

So if the length of xs is 0 then its 0. if not its 1 + the length of xs :confused: :confused:

Is xs a variable?
-10000 points!


(Only current students will get this one)
Reply 12
learner_dancer
-10000 points!


(Only current students will get this one)

KERCHING!
Azimuth
KERCHING!

Oh baby!
Reply 14
GoblinSoul
xs is the parameter that you send into f (a function).

Basically, if the length of the inputted parameter is NOT zero, then it will return "1 + f xs" which will call the function AGAIN (f xs), creating an infinite loop. (Unless somehow by adding 1 to the function, you manage to get back to zero - if the parameter was negative).

Although, I don't see the significance of posting a thread about this...


I see. So why is it so funny?
Hasan
I see. So why is it so funny?


Precisely

Oh look:


while(1);


LOLOL OMG BRILLIANT CODEZ!

...:rolleyes:

Might be amusing if you've never seen a loop before... possibly..?
Reply 16
You guys just make me feel like Newton, Thank you very much.
Reply 17
I find the Pascal compiler pretty funny.

Syntax error, ";" expected but "BEGIN" found

:facepalm2:
Reply 18
radicality
Clarification: It's Haskell

No wonder Haskel isn't used in the real world.
But then again someone still has yet to explain how SQL came about. The language is frigging backwards!
Mehh

But then again someone still has yet to explain how SQL came about. The language is frigging backwards!


Set theory. It's all pretty much a direct translation of the concepts from that (well, the relational parts at least)

Latest

Trending

Trending