I don't understand recursion

I don't understand recursion

UFOs Are A Psyop Shirt $21.68

Yakub: World's Greatest Dad Shirt $21.68

UFOs Are A Psyop Shirt $21.68

  1. 1 month ago
    Anonymous

    imagine shoving your hand so far up your own ass that it eventually makes its way down your arm and your fingers end up being around themselves

  2. 1 month ago
    Anonymous

    Obligitory, In order to understand recursion, you need to understand recursion.

    • 1 month ago
      Anonymous

      I've always hated that gay joke. Circular logic is not (good) recursion.
      >in order to solve n, you have to solve n-1
      >so when do you stop?
      >exactly
      not funny, but much more accurate

      • 4 weeks ago
        Anonymous

        You can have recursion that doesn't terminate.

        • 4 weeks ago
          Anonymous

          you sure can, it will just overflow the stack eventually and so is moronic. but that's not what
          >in order to understand recursion, you must understand recursion
          implies. that statement implies
          >def solve(n):
          >solve(n)
          as I said, that's not good recursion. the whole point is to solve n by solving a smaller problem (n-1).

          • 4 weeks ago
            Anonymous

            What an autistic hill to die on

          • 4 weeks ago
            Anonymous

            just doing my part to prevent the spread of moronation!

          • 4 weeks ago
            Anonymous

            you sure can, it will just overflow the stack eventually and so is moronic. but that's not what
            >in order to understand recursion, you must understand recursion
            implies. that statement implies
            >def solve(n):
            >solve(n)
            as I said, that's not good recursion. the whole point is to solve n by solving a smaller problem (n-1).

            you are such a wienersucking gay moron redditor it's insane

          • 4 weeks ago
            Anonymous

            I've always hated that gay joke. Circular logic is not (good) recursion.
            >in order to solve n, you have to solve n-1
            >so when do you stop?
            >exactly
            not funny, but much more accurate

            Your example is literally what's called a "tail" recursion, it's like a GOTO statement, so it doesn't increment the call stack.

            From wikipedia on tail recursion:
            > Many implementations achieve this by using a device known as a trampoline, a piece of code that repeatedly calls functions. All functions are entered via the trampoline. When a function has to tail-call another, instead of calling it directly and then returning the result, it returns the address of the function to be called and the call parameters back to the trampoline (from which it was called itself), and the trampoline takes care of calling this function next with the specified parameters.

            > Because tail calls are treated as jumps tail recursion can be used for indefinite iteration without fear of overflowing any sort of recursion stack.

            I herefore use this opportunity to call you dimwit.

          • 4 weeks ago
            Anonymous

            not all languages optimize tail recursion. my example being one of them. dimwit.

      • 4 weeks ago
        Anonymous

        Obligitory, In order to understand recursion, you need to understand recursion.

        imagine shoving your hand so far up your own ass that it eventually makes its way down your arm and your fingers end up being around themselves

        Since we into that
        Let's explain right way
        You want to show your hand up your ass
        You clone yourself and tell the clone to show his ass up your ass
        Your clone also wants to show his hand up his ass
        He creates another clone, clone of himself, clone of your clone
        He tell the clone to show his hand up his ass
        Now this clone clone also wants to show his hand up his ass
        He creates another clone, clone of himself, clone of the clone of our clone
        ...
        The process continues until universe is exhausted (stackoverflow/max call stack exceeded) or last clone is just a bit straight enough to not want showing his hand up his ass (exit/return condition reached).

  3. 1 month ago
    Anonymous

    Really, what seems to be the problem?

  4. 1 month ago
    Anonymous

    Anon what's the meaning of GIMP

    • 1 month ago
      Anonymous

      Gay is my peepee

  5. 1 month ago
    Anonymous

    (1) You are given a small problem,
    you know how to solve this problem directly
    so you do so and return the result.
    (2) You are given a problem that you don't know how to solve directly,
    but you know how to break it up into some smaller problems.
    So you break it up into those pieces and ask someone else to solve those smaller pieces.
    Then you take all the solutions you get back, combine them into a solution for the problem you were originally given and you return that.

    • 1 month ago
      Anonymous

      this.
      >at the theater
      >oh shit what row am I in
      1. ask the guy in front of you
      2. if he doesn't know, tell him to follow these steps and get back to you
      3. add 1 to what he tells you and report back

  6. 1 month ago
    Anonymous

    recursion is cope

    use while loops instead

    • 1 month ago
      Anonymous

      Recursion IS while loops. There's some implicit syntax sugar, but in the end it's just a loop with variable assignment.
      It all boils down to breadth first or depth first searching.

      • 1 month ago
        Anonymous

        >depth first
        while loop + lifo stack
        >breadth first
        while loop + fifo queue

      • 1 month ago
        Anonymous

        >There's some implicit syntax sugar
        This isn't true even in most languages.
        a function calling itself can blow the stack unless the compiler or interpreter has tail call optimization
        no such limitation exists for loops even in naive implementations

        • 4 weeks ago
          Anonymous

          >no such limitation exists for loops even in naive implementations
          well... the limitation is moved from the callstack to some heap structure.

      • 4 weeks ago
        Anonymous

        >he hasn't heard of the ackerman function

    • 4 weeks ago
      Anonymous

      just search on google some exercises, recursion is a difficult concept to gasp at first, but with a couple hours of exercises you'll understand it

      >filtered

  7. 1 month ago
    Anonymous

    It's easy.
    >Recursion solves recursive problems by using functions that call themselves from within their own code.

  8. 1 month ago
    Anonymous

    Read chapter 8, it starts at page 243
    https://www.cs.cmu.edu/~dst/LispBook/book.pdf

    • 1 month ago
      Anonymous

      Thank you for sharing that link.

  9. 1 month ago
    Anonymous

    anything you would use a loop for, you can also solve using recursion.
    recursion happens to be a convenient way to solve certain problems, especially ones with lots of branching paths.

    Try to implement depth first search using loops. Then try to implement it using a function that calls itself.

  10. 1 month ago
    Anonymous

    learn mathematical induction
    if that's too hard learn math

  11. 1 month ago
    Anonymous

    the return value for a recursive function is that same function with the original arguments but iterated in some manner. how is that hard to get?

  12. 1 month ago
    Anonymous

    function in a function
    simple

    • 1 month ago
      Anonymous

      vacuous statement

    • 1 month ago
      Anonymous

      It would be more accurate to say:
      function(function(XD))

      vacuous statement

      I enjoy your vocabulary. It is also fun to say out loud.

      • 1 month ago
        Anonymous

        >It is also fun to say out loud.
        you know what else is fun to say out loud?

  13. 1 month ago
    Anonymous

    recursion uses the memory stack so learn and understand that first.

  14. 1 month ago
    Anonymous

    >

    [...]


    unironically the best way to learn recursion

    • 1 month ago
      Anonymous
  15. 4 weeks ago
    Anonymous

    It's easy to understand recursion if you're dealing with any sort of problem involving graphs or trees, then it becomes very immediately intuitive. So, look into those.

  16. 4 weeks ago
    Anonymous

    funny dog

  17. 4 weeks ago
    Anonymous

    you ever had a really bad case of diarrhea from eating tacoslop that was on sale but because its onsale you just keep buying it to eart bacons ints on.sale?

  18. 4 weeks ago
    Anonymous

    >Iterator implementation: do X when the condition evaluates to true, usually time O(n) and space O(1)
    >Recursive implementation: figure out the condition it stops, set a base case to stop, then have to spend shit ton of brainpower to figure out if shit is correctly implemented in the tail recursion or else shit won't get called the right way on returning time, all this effort to implement it and never provides a constant space solution
    Only homosexual brainlets use unnecessary recursion in their code base fricking up the stack frame in the name of "m-muh recursion makes code readability better it's heckin elegant!!" when iterators are in many cases better than recursive implementation of some shit. You're not missing out for not understanding recursion.

  19. 4 weeks ago
    Anonymous

    what's not to understand?

  20. 4 weeks ago
    Anonymous

    ok imagine I make a function that can read one or more pages of posts.
    and it takes a parameter so you say how many pages you want to read.

    pages is 3

    it reads through a page, if pages > 0 then it calls the same function (this is the recursion bit) with pages-1 and adds to the result

    so now it keeps going

    pages is 2

    it reads through a page, pages > 0 then it calls the same function (this is the recursion bit) with pages-1 and adds to the result

    pages is 1

    it reads through a page, pages > 0 then it calls the same function (this is the recursion bit) with pages-1 and adds to the result

    pages is 0

    it reads through a page, pages == 0 so it adds to the result and the whole thing returns

  21. 4 weeks ago
    Anonymous

    Haha what stupid looking dog haha
    also you a moron

Your email address will not be published. Required fields are marked *