Post A7MCILEGH4EJ8pd1DU by caseyp@letsalllovela.in
 (DIR) More posts by caseyp@letsalllovela.in
 (DIR) Post #A7MBFaq1gRnMjHPz9s by mrjunge@raru.re
       2021-05-18T00:17:08Z
       
       0 likes, 0 repeats
       
       I'm starting to think maybe my initial approach was better, but it would still have me at a loss. How do I create a function where the number of nested loops required is explicitly specified? I guess the easy answer is here also "recursion," but I need to figure out what aspect of the input the number of recursions will be correlated with, since, from my experience so far, recursion depth is input-dependent.
       
 (DIR) Post #A7MCILEGH4EJ8pd1DU by caseyp@letsalllovela.in
       2021-05-18T00:28:54.074127Z
       
       0 likes, 0 repeats
       
       @mrjunge tail position recursion, if the optimization is done by the language impl, does not have that as the case
       
 (DIR) Post #A7MCVJ1HndZc3Pk0cC by mrjunge@raru.re
       2021-05-18T00:31:03Z
       
       0 likes, 0 repeats
       
       @caseyp Which part of my post is the "that"?
       
 (DIR) Post #A7MCdy4j2YOthaTq1w by caseyp@letsalllovela.in
       2021-05-18T00:32:48.599860Z
       
       0 likes, 0 repeats
       
       @mrjunge recursion depth being input dependant... Well, I assumed you meant stack depth by "recursion depth". Since you are recurring on an object, obviously the number of recursive calls itself is based on the size of the initial value
       
 (DIR) Post #A7MCfES9dJUImq2eNU by caseyp@letsalllovela.in
       2021-05-18T00:33:02.293830Z
       
       0 likes, 0 repeats
       
       @mrjunge maybe I just misunderstood you
       
 (DIR) Post #A7MD7qkwogbHgqThxo by mrjunge@raru.re
       2021-05-18T00:38:10Z
       
       1 likes, 0 repeats
       
       @caseyp Well, that is my fault for not using the right technical terms if so. But yes, I mean stack depth of a recursive function.
       
 (DIR) Post #A7MDTqgrk3nfrB3hyK by mrjunge@raru.re
       2021-05-18T00:42:09Z
       
       0 likes, 0 repeats
       
       @caseyp I'll look into what you mentioned.
       
 (DIR) Post #A7MQC0molVspMPfSYC by caseyp@letsalllovela.in
       2021-05-18T03:04:37.140421Z
       
       0 likes, 0 repeats
       
       @mrjunge idk where youre trying to learn programming or why but there may be a better way to approach it tbh, based on your posts I've seen
       
 (DIR) Post #A7NGnF0S3Q77nH7Ods by mrjunge@raru.re
       2021-05-18T12:53:59Z
       
       0 likes, 0 repeats
       
       @caseyp Idk what you mean. I looked up tail recursion and realized I've already learned about this. Not really related to my problem. That just seems related to performance, which isn't the issue here. Well, it could be but that is not what I am trying to solve. Python also just doesn't have that built in.I think I'm just not being clear. What I meant here in fewer words is, suppose I make a function where I input a number and that number has the function produce a certain stack depth through recursion, but *with a side effect* on a certain piece of data. How do you do that? Telling a recursion to have a stack depth unrelated to the actual data it acts upon, given stack depth depends on the input size.
       
 (DIR) Post #A7NH8KDlrQMg34OzMO by mrjunge@raru.re
       2021-05-18T12:57:46Z
       
       0 likes, 0 repeats
       
       @caseyp Anyway, this is just an additional problem that comes up if I choose this solution to my original problem. I decided against this.
       
 (DIR) Post #A7NKO24HQ9cSFA8zpo by mrjunge@raru.re
       2021-05-18T13:34:11Z
       
       0 likes, 0 repeats
       
       @caseyp And what would be the better way to approach programming? :blobcatThinking:
       
 (DIR) Post #A7NTSFntC2WPacZ6n2 by caseyp@letsalllovela.in
       2021-05-18T15:15:53.094653Z
       
       0 likes, 0 repeats
       
       @mrjunge I'm going to be honest, that  explanation still doesn't make any sense... Also, I can't even guess what problem you could possibly be trying to solve, but yes, this probably isnt the solution so good to decide against it.As for "better way to approach", I'm not particularly sure, I don't know exactly how you are or what you want to accomplish. More of, since you are, as you say, "not using the right technical terms" and this all feels related (just even seeing your other posts as well in passing) like the common situation in programming where someone asks a question about how to solve something but they would only need to solve it if they are doing something horribly wrong, it feels like something could be improved further back since a proper education would have neither of those be the case, ya know
       
 (DIR) Post #A7NU1JpqCDpsEECMeu by mrjunge@raru.re
       2021-05-18T15:22:10Z
       
       0 likes, 0 repeats
       
       @caseypOkay, how about I write puedo-code:n = how many times the function calls itselfd = some dictionarydef somefunc(d, n):  do something with d  if n, return somefunc(d, n) n-1The number of times the procedure on d is done is independent of the value of d. With n, you are directly declaring the stack depth of the recursive function.
       
 (DIR) Post #A7NUKY4bU1uTtCGzA0 by caseyp@letsalllovela.in
       2021-05-18T15:25:41.841510Z
       
       0 likes, 0 repeats
       
       @mrjunge thats just `for i in range (n): do something with d` in python, no?
       
 (DIR) Post #A7NURG4enn8I5pUu00 by mrjunge@raru.re
       2021-05-18T15:26:51Z
       
       0 likes, 0 repeats
       
       @caseyp There is nothing "horribly wrong" I am doing since what I'm trying to solve is purely a semantic error.
       
 (DIR) Post #A7NUplnsU6rtRxKxsG by mrjunge@raru.re
       2021-05-18T15:31:17Z
       
       0 likes, 0 repeats
       
       @caseyp Yes. If you see my previous post, I am using iteration. But I get false negatives with my conditional when using pure iteration (e.g., condition is d[i-1][e] == d[i]), and I am thinking of how to correct for that. One way is that for each element of the dictionary, I do a function like this.
       
 (DIR) Post #A7NV6geEuDSKNptZzM by mrjunge@raru.re
       2021-05-18T15:34:20Z
       
       0 likes, 0 repeats
       
       @caseyp That way I can arbitrarily go as deep as I want for each element in making the comparison. I gave up on this solution. I'm also at the point where I think it's a dead-end solution if it is difficult to explain. I also made a recent post where I realized I don't need an arbitrary stack depth because, logically speaking, for my loop conditional to work as I want, I just need to look at one additional level below the sequence if it fails, so it does what I want it to.
       
 (DIR) Post #A7NVb8YrgmyPdttwjQ by mrjunge@raru.re
       2021-05-18T15:39:50Z
       
       0 likes, 0 repeats
       
       @caseyp Basically, the reason I thought of this instead of just adding another loop is *I don't know ahead of time how many loops I'd need to do.* Otherwise yeah I could just nest my loops. But, turns out I do, so this is no longer relevant.
       
 (DIR) Post #A7NVp8urAQJanSrlWC by mrjunge@raru.re
       2021-05-18T15:42:20Z
       
       0 likes, 0 repeats
       
       @caseyp Deleted previous posts because I think this pretty much sums it up better. Yeah, you're right, but also, no. Because this function unlike a mere loop would allow me to adjust number of nested loops themselves, arbitrarily, in theory.
       
 (DIR) Post #A7NW28w8OyFScpfAPY by caseyp@letsalllovela.in
       2021-05-18T15:44:46.844293Z
       
       0 likes, 0 repeats
       
       @mrjunge Recursion and iteration are equivalent in terms of computational expressability ... You can always transform one into the other
       
 (DIR) Post #A7NWNehjU9MrETBVAW by mrjunge@raru.re
       2021-05-18T15:48:37Z
       
       0 likes, 0 repeats
       
       @caseyp That makes sense theoretically, but doesn't tell me much in practice. So what do I do if I don't know how many nested loops I want, i. e. how "deep" I want to go in an array? Infinite conditional sub-loops? Or the ability to declare an arbitrary number n as in the prev function?
       
 (DIR) Post #A7NWS1YCU9lZFNoDR2 by mrjunge@raru.re
       2021-05-18T15:49:25Z
       
       0 likes, 0 repeats
       
       @caseyp The question is impossible, is what I think.
       
 (DIR) Post #A7NWVbR7WG0lPiChDk by caseyp@letsalllovela.in
       2021-05-18T15:50:06.256224Z
       
       0 likes, 0 repeats
       
       @mrjunge Wait, so what kind of data are you trying to iterate over? Its a dictionary right? From Num -> List of <Data>?
       
 (DIR) Post #A7NXbmDSSBgyXPJyHQ by mrjunge@raru.re
       2021-05-18T16:02:22Z
       
       0 likes, 0 repeats
       
       @caseyp I am using a dictionary to represent a nested sequence. So each item represents a level in a nested sequence. So yeah, I can loop over the items or do a recoursive function on it. But what I want to do is reconstruct the original nested sequence based on the dictionary data, but with some new items at given levels. This would theoretically work just looping through and comparing subitem of a previous item with a next item in the dictionary and then, if equivalent, replacing that previous item's subitem with the new version of that next item. The problem is I get false negatives because of the way this dictionary representation was made from the initial sequence. However, I realized that I DO know how many nested loops I would need at minimum, on that same basis, since there should be no more false negatives past a nesting loop size of 2 (this is because each dictionary item is only one level lower than the previous). So problem is now solved. Maybe.
       
 (DIR) Post #A7NY568hSU6sj74qGW by mrjunge@raru.re
       2021-05-18T16:07:40Z
       
       0 likes, 0 repeats
       
       @caseyp This whole other nonsensical branch of thought we started off with was just some divergent thinking due to not knowing the required "depth" I would need for each previous item to take care of false negatives. I think what I was asking about was essentially just impossible. There is *always* information from inputs relevant to determining the number of loops to solve a problem. Just arbitrating it, even if in so doing one is trying to use some other indepemdent value, makes no sense. Which I guess reinforces what you said about iteration and recursion.