Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-4041-

Recursion HALP

Name: Anonymous 2011-06-01 2:33

Hey /prog/, I must say my understanding of recursion is shit (never really dealt with recursion in all my days of writing bad code). How should I go about thinking about it?

inb4 flaming: I understand the recursive concept in some contexts, such as when it is used in a factorial function, but when it starts getting more ambiguous (say, exercise 5, ch. 2 from ANSI Common Lisp) it's ugly.

inb4 RECURSE MY ANUS

Name: Anonymous 2011-06-01 2:36

YOU SAID IT BEST WHEN YOU SAID "RECURSE MY ANUS"
thread

Name: VIPPER 2011-06-01 3:52

HALP
No

Name: Anonymous 2011-06-01 4:26

<spoiler>...... RECURSE MY ANUS .......</spoiler>

Name: Anonymous 2011-06-01 5:33

>>5

Name: Anonymous 2011-06-01 18:35

>>6

Name: Anonymous 2011-06-01 18:45

Try expanding the recursive calls: (fact 5) ==> (* 5 (fact 4)) ==> (* 5 (* 4 ...))

(Do this for whatever function it is you don't understand.)

Name: Anonymous 2011-06-01 19:48

>>7
2/10 for baiting the retard.

Cripes you suck. Go fuck off. Your explanations are weak and your code examples suck dick.

Name: Anonymous 2011-06-01 19:50

>>7
And just for the record you little fucking nigger, your shit example could give people the wrong idea about how recursion could work. This is because not every fucking programming language handles recursion the same way. This is partially due to the fact that the definition of a "variable" tends to vary.

Name: Anonymous 2011-06-01 19:52

>>9
Fuck you on? That's how an unoptimised recursive problem is solved by the computer.

Name: Anonymous 2011-06-01 19:58

>>10
There are a couple of ways a computer could solve an unpotimised recursive problem you fucking moron.  Of coure the only way you would know something like this is if you actually read something other than SICP.

Name: Anonymous 2011-06-01 20:00

>>11
In other words you little fucking nigger, your use of the world "solve" is ambiguous in this case.

Name: Anonymous 2011-06-01 20:04

>>11
No, you cuntlegging shiteyed pissmonger. Each step in >>7 is just like looking the state of the stack before the next recursive call. Tell me wanknibbler, what's the other way a stack-based computer would solve this? That is, the solution that doesn't involve building up a stack and having it look like one thing in >>7 at some point in time.

Name: Anonymous 2011-06-01 20:10

>>13
Are you this fucking stupid? Maybe you should stop giving shit advice and actually read a book. With that you fucking stupid shit, you are still being ambigous.

First off you don't specify the evaluation order. At what point and time do you actually calculate the values in the recursion? Second thing you fucking moron, you don't give a clear definition of the term "variable". Is the variable meant in the C/C++ sense or in the math sense? Finally, not every computer uses a stack.

Name: Anonymous 2011-06-01 20:14

>>14
I never said 'variable', you mentalist. Stop fabricating memories.
Of course there's ambiguity in evaluation order, because >>7 does not fully show the entire evaluation.
Finally, yes I am aware that there are indeed some computers that do not use stacks. But all of the valves in those computers have long since died.

Name: Anonymous 2011-06-01 20:19

>>15
Listen you stupid fuck. You had

(fact 5) ==> (* 5 (fact 4)) ==> (* 5 (* 4 ...))


'fact' is a fucking variable. Also evaluation order isn't the same thing and showing the entire evluation. Again, are you really this fucking stupid?

Name: Anonymous 2011-06-01 20:23

>>15
And more to the point your fucking stupid shit nigger. When you have something like....

(fact 5) ==> (* 5 (fact 4)) ==> (* 5 (* 4 ...))

At what point and time do you evaluate fact to a value? At what point and time do you multiply 5 * 4 *...? Your shit diagram doesn't really answer these questions.

Name: Anonymous 2011-06-01 20:23

er *point you fucking shit shit nigger.

Name: Anonymous 2011-06-01 20:25

*

Name: Anonymous 2011-06-01 20:25

>>16
... 'fact' is the name of the function. It could be variable, but in a factorial, it most often is not.
And showing the entire evaluation will show you the order of evaluation.

Are you done trolling?

Name: Anonymous 2011-06-01 20:27

>>17
Ho jeez.
You evaluate 'fact' to a value on the base case. And seeing as 99% of computers are stack-based, you would evaluate 5 * 4 * ... essentially right-to-left, according to your fucked-up infix representation.

Name: Anonymous 2011-06-01 20:28

>>17
Also,
*point in time
And please sage. You are a cunt.

Name: Anonymous 2011-06-01 20:30

>>20
Umm.... a function can be a variable. This happens more often than what you think you fucking moron.

Again, you are stupid. Also, showing the entire evaluation will not show you the order of evaluation. Again, at what point and time you do evaluate 'fact' to a value? At what point and time do you multiply all the numbers? Again, you don't bother to explain it. So again, until you can answer my questions, you should maybe stop giving shit advice, learn a few more programming languages, and attempt to write a compiler before you open your dumbass mouth again.

Name: Anonymous 2011-06-01 20:31

>>21
But like what I just asked the dumb nigger that was giving out the shit advice, at what point and time do you multiply? Now the whole concept of 'time' shouldn't be that foreign since SICP actually discusses this topic.

Name: Anonymous 2011-06-01 20:34

>>23
Again, why don't you fist F5 before repeating yourself?
Umm.... a function can be a variable.
Well done. I acknowledged this in the very post you were referencing. Observe:
It could be variable
Now, rinse and repeat for every fucking thing you decided to blurt out in your latest rambling, regardless of how many times you have repeated yourself. If you cannot find an answer, please redirect yourself to /g/ or /sci/ or something.

Name: Anonymous 2011-06-01 20:35

>>25
Well you uneducated nigger, you still can't answer the questions. So again, maybe you should stop giving out shit advice on something that you clearly don't understand and actually read a book.

Name: Anonymous 2011-06-01 20:36

>>25
Also, I never gave a definition to the term 'variable'.

Name: Anonymous 2011-06-01 20:38

>>27
So now it is you who is being ambiguous. How delicious.
>>26
May I point out that my first post in this thread was >>10.
I'd also like to suggest you take a course on argumentation. And re-read >>22.

Name: Anonymous 2011-06-01 20:44

You still haven't answered the questions. Is the variable a variable in the C/C++ sense or the math sense? You're shit diagram doesn't say. Again, for the third time, and what point and time do you evaluate fact? I don't see this in your shit diagram. Again, for the third time, what point and time do you do the multiplications? Again, your shit diagram doesn't tell.

And again, until you can answer my questions, your silence will just reaffirm my belief that you are some uneducated nigger that has never done any kind of real programming for a living.

Name: Anonymous 2011-06-01 20:50

>>29
Are you even reading my responses?
fact could be a variable. It does not vary in most implementations of factorial. It is a function, which is not a mathematical variable. Therefore it could be a "C/C++" variable. IHBT. You cease expanding (and thus start evaluating) fact when it becomes the base case, here it is 1. So the diagram (not my diagram, please refer to >>28) would end up as (* 5 (* 4 (* 3 (* 2 (1))))) before the evaluation of the products. Which is the point and time (?,>>22) that you start to "do" the multiplications.

Now please, stop being an anus, I've had to repeat myself as many times as you here.

Name: Anonymous 2011-06-01 20:56

>>30
"Therefore it could be a "C/C++" variable"

Okay, it's about time you answered the question.

"would end up as (* 5 (* 4 (* 3 (* 2 (1))))) before the evaluation of the products"

No, that isn't how it works if you define a variable in the C/C++ sense. Now before you get your panties in a bundle about this one, write a simple recursive fact program in C++ and then have it do something like the factorial of 2000! Do you get an exact number? I don't.

Name: Anonymous 2011-06-01 21:03

>>31
No, because with languages that do not bundle bigint support, it would overflow a 32-bit computer (and probably a 64-bit one too). Floating-point would have a similar story. Please define ``exact number''.
I said it was a function, and that it could (note the emphasis) be a "C/C++" variable in that you can pass it to another function as, say, a callback or something. You cannot call a "regular" variable (int, float, ...) as you would call a function. What does your example have to do with variables versus functions, anyway?

Clearly fact in >>7's example is being called as a function, not a variable ("C/C++", by which you mean Lisp) and (* 5 (* 4 (* 3 (* 2 (1))))) is merely a simplified representation of the stack, obtainable via iterative substitution.

Name: Anonymous 2011-06-01 21:04

Also, I'm going to bed. Enjoy throwing poor insults at the next person who decides to pick this up. Don't forget to ignore 90% of what they say, now.

Name: Anonymous 2011-06-01 21:10

>>32

"Please define ``exact number''"

A number that isn't an approximation.

"What does your example have to do with variables versus functions, anyway?"

Some languages treat a function as a variable.



Again, you're confused you nigger. Something like the following...

"(* 5 (* 4 (* 3 (* 2 (1)))))"

Can have different meanings depending on the language.

"is merely a simplified representation of the stack, obtainable via iterative substitution. "

You're confusing an expression with its actual variable.

Name: Anonymous 2011-06-01 23:01

YO DAWG I HEARD YOU LIKE RECURSION SO I PUT A RECURSIVE FUNCTION IN YOUR RECURSIVE FUNCTION SO YOU COULD RECUSE WHILE I PUT A RECURSIVE FUNCTION IN YOUR RECURSIVE FUNCTION SO YOU COULD RECUSE WHILE I PUT A RECURSIVE FUNCTION IN YOUR RECURSIVE FUNCTION SO YOU COULD RECUSE WHILE I PUT A RECURSIVE FUNCTION IN YOUR RECURSIVE FUNCTION SO YOU COULD RECUSE WHILE I PUT A RECURSIVE FUNCTION IN YOUR RECURSIVE FUNCTION SO YOU COULD RECUSE WHILE I PUT A RECURSIVE FUNCTION IN YOUR RECURSIVE FUNCTION SO YOU COULD RECUSE WHILE I PUT A RECURSIVE FUNCTION IN YOUR RECURSIVE FUNCTION SO YOU COULD RECUSE WHILE I PUT A RECURSIVE FUNCTION IN YOUR RECURSIVE FUNCTION SO YOU COULD RECUSE WHILE I PUT A RECURSIVE FUNCTION IN YOUR RECURSIVE FUNCTION SO YOU COULD RECUSE WHILE I PUT A RECURSIVE FUNCTION IN YOUR RECURSIVE FUNCTION SO YOU COULD RECUSE WHILE I PUT A RECURSIVE FUNCTION IN YOUR RECURSIVE FUNCTION SO YOU COULD RECUSE WHILE I PUT A RECURSIVE FUNCTION IN YOUR RECURSIVE FUNCTION SO YOU COULD RECUSE WHILE I PUT A RECURSIVE FUNCTION IN YOUR RECURSIVE FUNCTION SO YOU COULD RECUSE WHILE I PUT A RECURSIVE FUNCTION IN YOUR RECURSIVE FUNCTION SO YOU COULD RECUSE WHILE I PUT A RECURSIVE FUNCTION IN YOUR RECURSIVE FUNCTION SO YOU COULD RECUSE WHILE I PUT A RECURSIVE FUNCTION IN YOUR RECURSIVE FUNCTION SO YOU COULD RECUSE WHILE I PUT A RECURSIVE FUNCTION IN YOUR RECURSIVE FUNCTION SO YOU COULD RECUSE WHILE I PUT A RECURSIVE FUNCTION IN YOUR RECURSIVE FUNCTION SO YOU COULD RECUSE WHILE ...

Name: Anonymous 2011-06-02 1:28

>>35

re·cuse

verb /riˈkyo͞oz/ 
recused, past participle; recused, past tense; recuses, 3rd person singular present; recusing, present participle

   1. Challenge (a judge, prosecutor, or juror) as unqualified to perform legal duties because of a possible conflict of interest or lack of impartiality
          * - a motion to recuse the prosecutor

   2. (of a judge) Excuse oneself from a case because of a possible conflict of interest or lack of impartiality
          * - the Justice Department demanded that he recuse himself from the case

Out. Now.

Name: Anonymous 2011-06-02 2:11

>>8-9,11-12,14,16-19,23-24,26-27,29,31,34-35
That's how SICP teaches recursion, maybe you should read it, stupid troll.

>>7,10,13,15,20,25,28,30,32-33
Please, try to refrain from getting trolled by such low level trolls.

Name: >>7 2011-06-02 4:45

>>8-9,11-12,14,16-19,23-24,26-27,29,31,34

OKAY YOU FUQIN ANGERED AN EXPERT PROGRAMMER
GODFUCKIGNDAMN
FIRST OF ALL, YOU DONT FUQIN KNOW WHAT EXPANSION IS
SECONDLY, THIS WHOLE FUQIN THREAD IS ABOUT UNDERSTANDING RECURSION, NOT YOUR ``EXACT NUMBER'', ``VARIABLE'', OR ``STACK'' BULLSHIT
THIRDLY SICP IS ALL ABOUT RECURSION AND ``ABSTRACT BULLSHITE'' THAT YOU WILL NEVER COMPREHEND
AND FUQIN LASTLY, FUCK OFF WITH YOUR BULLSHYT
EVERYTHING HAS ALREADY BEEN ANSWERED IN >>3,4,7

Name: Anonymous 2011-06-02 8:14

>>34
You're too stupid for words. Even if you were trolling initially, you've clearly put enough effort into this such that you must believe yourself by now.
Obviously the representation chosen by >>7 is not language-independent.
Some languages treat a function as a variable.
>>20,25,32

Regarding the rest of >>34... Please refer to the first sentence in >>10.

Name: Anonymous 2011-06-02 10:02

>>37
Tell us again what you do for a living you stupid shit.

Name: Anonymous 2011-06-02 10:04

>>39
Please tell us what you do for a living you stupid fucker.

Name: Anonymous 2011-06-02 10:09

>>40-41
Please tell me what you do for a living.

Name: Anonymous 2011-06-02 10:16

>>40,41
You're still at it? Bless.

Name: Anonymous 2011-06-02 10:54

Oh my God D:, you guys scare me.

Name: Anonymous 2011-06-02 11:04

>>44
D:
Stop that.

Name: Anonymous 2011-06-02 11:06

>>45
D:,
It clearly had one eyebrow raised.

Name: Anonymous 2011-06-02 11:11

>>46
Sorry ··`

Name: Anonymous 2011-06-02 11:48

:D=3

Name: Anonymous 2011-06-02 13:31

8==D

Don't change these.
Name: Email:
Entire Thread Thread List