What's recursion?

What's recursion?

Other urls found in this thread:

youtu.be/hrwwJjt71yw?t=53
twitter.com/SFWRedditGifs

Function calling itself

What's recursion?

if you don't understand what recursion is, reread this sentence

A gay and inefficient way for mediocre CS students to feel clever

>What's recursion?
Something you should never do except in functional languages.

If you write recursive functions in C or Python, end yourself.

These other posts really prove this point

>He doesn't use recursion in VHDL
Shiggy

haha just nerd things xD i am so nerdy such a nerd xD

continuations in C are better

sometimes it's justifiable

> iterative ray tracing
> iterative merge sorting

It's only inefficient if you're using a retarded language and compiler.

PHP is a recursive acronym

A bad practice. Was basically abolished in 50s until functional cucks came.
Personal Home Page

What's recursion?

Recursion is like recursion but in easier

>What is analysis of algorithms?
>What do you mean computational complexity does not depend on language and compiler?

I'm surprised how this is something people even boast or theorize about. Doesn't everyone "discover" recursion on their own at some point?

To discover recursion, you must first discover recursion.

>>What is analysis of algorithms?
>>What do you mean computational complexity does not depend on language and compiler?

t. doesn't program

youtu.be/hrwwJjt71yw?t=53

What's recursion in Java?

t. doesn't know what asymptotic time complexity notation is

>he doesn't know about tail recursion.
>he uses a shit language that compiles tail recursion out

What's recursion?

this is recursion

fuck no wait, this is recursion

>off by one

Great example user

This is recursion, OP:

> he thinks time complexity is the only one that matters
Tail recursive implementation of factorial function with a smart compiler will have constant memory complexity, whereas stupid compiler will overflow stack immediately (linear memory complexity).

Turns out first yeas CS education doesn't teach you everything that there is to know, who could have thought?

What.
The.
Fuck.

>if your compiler turns it into iterative behind the scenes, then it stops crashing and/or being slower and becomes almost just as fast!
Wow, good job. Such a convincing defence of recursion.

>Turns out first yeas CS education doesn't teach you everything that there is to know, who could have thought?
Didn't your CS lecturer teach you that there's mathematical proof that whenever there is a recursive solution, there always is a computationally less complex iterative solution as well?

Git gud.

recursion is a meme

My point stands. Recursion is inefficient only if the compiler is stupid.

Less complex iterative solution? You either meant "no more complex" or you are a complete idiot. I will generously assume the same and will ad that the inverse statement is also true: whenever there is an iterative solution, there is also a recursive solution with no more complexity.

As for my lecturer, I'm not a university fag.

>Didn't your CS lecturer teach you that there's mathematical proof that whenever there is a recursive solution, there always is a computationally less complex iterative solution as well?
Haven't heard that one before.

*assume the former
*add that
Sorry mate.

a way of thinking through a problem that you wont generally need to use but should be thinking about time and time when trying to solve a problem

solving a problem iteratively makes sense most of the time and is the 'correct' way, but some problems can actually be reduced in complexity by using recursion

just dont throw it on everything

you might know it by its leddit name, meta.

You are retarded. There is no concept of functions in x86 assembly, therefore there cannot be recursion. How do you think all your recursive programs run on your computer?

Please See

>now you remember prolog classes
fuck this dumb retarded bullshit

>being this dumb

You're wrong and you should stop pretending to be smart. You don't know what proper tail calls are and you're confusing an implementation detail, recursive instead of iterative, with time complexity.

I love how recursivefags' only defense is blaming the compiler for not covertly converting their code to iterative under the hood before turning it onto object code, .

Such a pathetic crowd...

I love how recursivefags' only defense is blaming the compiler for not covertly converting their code to iterative under the hood before turning it onto object code.

Such a pathetic crowd...

Did you guys fall asleep during CS 101?

import java.recursion

>what is abstraction
>what is convenience
>what do you mean computers are smart enough to do the annoying busywork for us

uhhh NO? back the fuck off with youre redicculous claims b-baka~!!!! i wrote an imperative delcarative lisp implenetaiton in Haskell using recursion it has real world uses too i promise

Piss off, you're leaving straw all over the place

I seriously do not understand why so many people are autistically opposed to recursion. It's a legitimate programming technique/concept.

maybe you could clean it up

...

Because in most mainstream languages it imposes an unnecessary cost to the runtime while not being anything other than an easier/more intuitive way of writing some algorithms. So there's literally no advantage other than saving you some coding time which means it should not be used period.

base case

>what is obfuscation?

...

int definition_of_recursion(int x)
{
return(definition_of_recursion(x));
}

java.lang.StackOverflowError

>muh runtime

It's not 1995 anymore gramps.

>So there's literally no advantage other than saving you some coding time
>implying that isn't an advantage in this era of development

nice try, my brother died trying to do that

...

>>So there's literally no advantage other than saving you some coding time
>>implying that isn't an advantage in this era of development
this is the most retarded thing i've ever read well done

>So there's literally no advantage other than saving you some coding time which means it should not be used period.

They basically said that it shouldn't be used. Therefore they were implying that it really wasn't an advantage. Lean logic.

a property that is, in particular, true for our number system which states that any numerical statement that is true for a subset of reals then it is true for the entire set.

Yeah, abstraction is useless and for babies anyway, who needs it?

Recursion is a function that calls itself.

If you do not like do(...){while}/while/for/foeach loops, recursion can be your choice
package main

import "fmt"

func loop(n int16) int {
fmt.Println(n)
if n != 0 {
loop(n - 1)
}
return 0
}

func main() {
loop(10)
}


user0@primary:~/testdir/go$ go run main.go
10
9
8
7
6
5
4
3
2
1
0
user0@primary:~/testdir/go$

>Arm's-length recursion
>Go
Absolutely disgusting.

Sorry, I forgot my (You):

What's your point again?

That you're a faggot, your code is shit, and you should probably stop programming.
int loop(int n) {
if (n < 0)
return 0;
return loop(n - 1);
}
Is the much better way to do it.
I don't know why this function returns an int, though.

NERVE GAS

Also, I forgot to put the print statement before the return, but I was just trying to get the structure across.

Do you have trouble in talking to people too?

>Try to be detailed, easy to understand towards OP
>"lul luk at me, ur code is shit but look at me, I can 1337ify your code"

underrated

...

If you do arm's-length recursion, it probably means that you're a stupid non-CS babby, and don't even understand recursion properly.
void walk_binary_tree(tree *node)
{
// Simple, elegant, no duplicated code
if (!node)
return;

// No unnecessary nesting
walk_binary_tree(node->left);
do_thing_with_node(node);
walk_binary_tree(node->left);
}
vs
void walk_binary_tree(tree *node)
{
// HURRRR
if (node->left)
walk_binary_tree(left);

do_thing_with_node(node);

/// DURRRRR
if (node->right)
walk_binary_tree(right);
}

Are you actually proud to be a C(((S))) toddler?

>1337ify
Not him, but his sample is standard recursion practice, and it's a good thing to know.

Why even bother trying to help someone else if you take criticism this badly?

If you don't want to improve, that's fine, but don't try to help beginners, you're doing them a disservice.

Please user, it's (((C)))(((S))).

Yeah, you are doing them a good service by screaming for some attention instead of trying to explain what the topic is 10/10

>(((C"""S""")))

Again, not the guy you were replying to originally, but arms-length recursion is bad for many reasons, and you have no right to explain anything recursion-related to anyone at all if you think your solution was acceptable.

You sperging out like this at the slightest criticism just proves my point. If you don't understand why your solution was subpar, you shouldn't be explaining recursion to anyone, end of story.

This guy gets it.
No one does recursion in the real world because it obfuscates code but brings absolutely no benefit in trade off whatsoever.

>IQ : 160+
Physics, Maths
>IQ 150+
Pharmacy, Medical Science
>IQ 140+
Various Engineering except for Software Engineering
>IQ 125+
Pick a side
>IQ < 125
Computer science, software engineering, IT, infosec, Liberal arts etc

CS is simply applied combinatorics

recursion is a jewish trick

Do not fall for the recursive jew

What the fuck?

>user what is a while loop?
Me: It's just like if statement, but repeated, give the simplest of simple example possible for someone who just learnt if
You: [Instead of explaining to user directly]
>HURR DURR HURR GRRR
>what
>UR CODE IS SO SIMPLE YOU SHOULD NOT TEACH SIMPLE CODES LUK HOW MY SOPHISTICATED WHILE FOREVER LOOP LOOKS LIKE DURR
>HURRURURR Y U NO CODE LIKE MY ULTRA SOPHISTICATED STYLE, PLEB YOU ARE MAKING user PLEB UNLIKE ME HURR RRRHUR

I already know Sup Forums is full of 14 y/o edgy preteens but it's too hard and shameful for me to admit.

Fizzbuzzers love binary trees. It's almost meme tier at this point.

These are the same kids that push "MUH FUNCTIONAL HASKLEL MEEMLANG" onto newfags' ass and pretend to be 1337

NOTHING is more cringe invoking than these underage dipshits.

>simplest of simple example possible
It's not though

arm's length recursion is fundamentally confusing, and it's beyond me why you decided to give such an example to a beginner.

if you're such an expert, why couldn't you just do it the proper way? are you trying to flaunt your knowledge of convoluted code to beginners?

if you still don't understand why people are getting mad at your post, just leave buddy.

>people are
I am*. I can tell you are the person I replied by the style of your spacing.

that was my first post in this thread, but nice try. you aren't nearly as clever as you think.

let me ask again: if you are such an expert on recursion, why couldn't you give a proper example?

shut up fag

>can't tell the difference between a recursive procedure and a recursive process

Wowee, CS classes must be real shitty now.

If anyone feels the same way as this guy, I recommend you read the first chapter of SICP.

Can't wait until functional cancer dies.

It's like the "feminine penis" of Sup Forums.

(You)
(You)

>le sicp meme
That book is literal garbage. I've never met a single professional who had even ever heard about it.