75 questions
1
vote
1
answer
99
views
Why am I getting this RecursionError?
I'm working on making a program to read a chart of accounts and turn it into a tree of Account objects, which I will be doing stuff with later. The chart of accounts in question has several levels of ...
0
votes
1
answer
109
views
Creating menus with options that select other menus, without causing stack overflow due to recursion
I want to create menus with options that select other menus, without causing a stack overflow error due to recursion.
But the menus have to be initialized, and a menu a can point to a menu b and b to ...
3
votes
1
answer
86
views
Question about Node js infinite recursion and async/await behavior [duplicate]
I've been trying to make an infinite loop in Node js, and came across this problem. I experimented a bit and came up with these three functions.
async function rc1(){
rc1();
}
//-> stack ...
4
votes
1
answer
228
views
Method listen URLSessionWebSocketTask without recursion
When called, the method of URLSessionWebSocketTask.receive(completionHandler:), receives only one message.
So in order to continue receiving messages I need to call this method again and again. This ...
-1
votes
2
answers
87
views
How to change the base case so it starts recursion all over?
I am trying to force a recursion to loop infinitely for a project of mine.
This is my code up so far:
putStr' :: String -> IO ()
putStr' (a:as) = do putChar a
putChar '\n'
...
2
votes
1
answer
325
views
Pythons `__getattr__` + `torch.nn.Module` yields infinite recursion
I wrote a simple wrapper to add special methods to a given PyTorch neural network.
While the implementation below works well for general objects like strings, lists etc. I get a RecursionError when ...
0
votes
1
answer
164
views
Infinite recursion from spreading map tile modification algorithm - why is it happening, and how can it be fixed?
The code in the Stack Snippet is meant to work as follows:
Click the table cell in the top right corner, which has a value of 0
The value will instantly change to 4
After a delay, the numbers in the ...
0
votes
1
answer
94
views
Python InfiniteDefaultRevisionDictionary, any implementations?
In programming, certain dictionary-based data structures are very useful and important. For example:
Revision dictionary:
Revision dictionary is a sub-type of dictionary that keeps keys sorted in the ...
2
votes
0
answers
126
views
How to capture and log infinite recursion errors in production PHP?
Recently I had a problem where because of invalid data in DB some PHP script ran into an infinite recursion on production. We have Sentry added in our system for error log management, but that did not ...
0
votes
1
answer
265
views
Recursive method to return substring enclosed in characters
I can't use other methods or add parameters and can only call the method recursively. I can't really understand how to approach this problem. I am struggling a bit wrapping my mind around recursion so ...
1
vote
1
answer
69
views
Want to update 2 input state values dynamically without recursive calls
I am making a React application for a currency converter website. I have two <input> fields where the user can input the number to get the exchange rate as shown here:
Screenshot of Component
...
0
votes
1
answer
88
views
What's causing infinite recursion in my Rust Red-Black Tree insertion code?
How do I stop infinite recursion on the following code? I am having a problem creating the parent link to a node being inserted. If you remove the 2 lines
node.parent = Some(parent.clone()); x2
The ...
0
votes
0
answers
47
views
Using a variable outside its function
I want to use the checkedCount variable inside of the generatePassword function in order to not call the function matrixEffect at the end of generatePassword if the value of checkedCount is 0.
I used ...
0
votes
0
answers
108
views
How do I avoid infinite recursion when checking if a chess move is legal?
I am creating a chess game in Python for a school project, but don't know how to check if a move is legal without causing a stack overflow.
My algorithm works by making the move
Checking if the king ...
0
votes
1
answer
95
views
Given an adress, how can I access the object in Python?
How can I access a Python object by it's address that I get from id(self.__dict__)?
The background is the following, I want to access one class instance from the other (both classes mimic custom ...
3
votes
4
answers
153
views
Infinite lists that depend on each other in Haskell?
I am working on a programming exercise where the goal is to write a function to get the term at the Nth index of Hofstadter's Figure-Figure sequence.
Rather come up with a basic solution using the ...
1
vote
3
answers
140
views
Python Dynamic Programming Problem - ( 2 dimension recursion stuck in infinite loop )
In the book "A Practical Guide to Quantitative Finance Interview", there is a question called Dynamic Card Game, 5.3 Dynamic Programming)
The solution according to the book is basically the ...
1
vote
2
answers
353
views
C# 10.0 - How should I work around this particular "chicken and egg" problem involving two object that contain each other?
So I'm working with code in which there are two object that contain each other, inside a list of which I do not know the contents of until runtime. I have a function that needs to convert the first ...
0
votes
1
answer
226
views
Typescript Type Flatten Child nested objects
i have been following this example and here to flatten a type invain. Most of this flatten the object completely into removing the nests. I would like to to maintain my structure, just removing ...
-2
votes
1
answer
125
views
Property setter triggers infinite recursion, why?
Using the @property + setter encapsulation, I need a class that raises an exception when someone tries to change the account_number. However, in the __init__ function, I need to set the value. This is ...
0
votes
2
answers
970
views
Getting infinite recursion with ObjectMapper even though entities' fields are annotated with @JsonIgnore
Got two entities:
class Entity1{
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "entity1Id", unique = true, nullable = false)
private Integer entity1Id;
@OneToMany(mappedBy = "...
0
votes
1
answer
46
views
Python Recursion not exiting the function, Find the last index of 'x' in the 'arr' recursively
Read input as specified in the question
Print output as specified in the question.
arr=[34, 57, 82, 41, 65, 35, 82, 27, 36, 12, 6, 40, 66, 99, 25, 29, 22, 25, 12, 24, 65, 15, 5, 43, 28, 33, 76, 32, 13,...
1
vote
1
answer
306
views
Why does the compiler issue a template recursion error?
I'm currently trying to deduce a std::tuple type from several std::vectors that are passed as parameters. My code works fine using gcc, but the compilation fails with Visual Studio Professional 2019 ...
0
votes
0
answers
61
views
C : Binary tree infinite recursion problem
I can't seem to find where the problem is in my code, i'm essentially storing character patterns, if an existing pattern is already present I'll store it in the duplicate node, otherwise it will shift ...
2
votes
2
answers
726
views
Implementing N choose K recursively in Java
I am new to Java and am I trying to implement a recursive method for finding "n choose k".
However, I've run into a problem.
public class App {
public static void main(String[] args) throws ...
1
vote
1
answer
613
views
Recursive function to calculate the children of a parent
I have a set of data that looks like this:
Person1 is the parent of Person2
Person2 is the parent of Person3 and Person4
Person3 is the parent of Person1
If I try to calculate the whole tree for ...
0
votes
1
answer
377
views
How to execute AST or code object in a separate process without exceeding max recursion depth
I am trying to write a metamorphic quine. Without the "spawn" context, the subprocesses seem to inherit the stack, and so I ultimately exceed the max recursion depth. With the "spawn ...
0
votes
3
answers
121
views
Not sure why I'm stuck in a Python stuck recursion loop
The add and mul definitions here are nonsensical because of their dependence on returning self, causing infinite loops. If they create a new distribution using the lambdas then it works fine, as in my ...
0
votes
0
answers
67
views
Stack Overflow Exception in Recursive Program Due to Missing Check
I am battling with this puzzle where I have a small, recursive program that is sort of similar to Conway's life. It has a set of octopuses arranged in a 10x10 grid, and each one has an energy level ...
0
votes
0
answers
215
views
R markdown knitting error (infinite recursion)
I am trying to knit an R markdown document into pdf, but it keeps failing and shows this message only:
Error: evaluation nested too deeply: infinite recursion / options(expressions=)?
Execution halted
...
0
votes
1
answer
370
views
What is the best way to build own system metric collector agent
Myself have an idea to build own metric collection agent for linux systems with various customised features and controls. Would like to know what is the best practice to collect metrics continuous ...
-3
votes
3
answers
405
views
Infinite recursion with if statement in Python
I have this code:
def get_girlfriend():
res = input("Will you go out with me? ")
if (res == "y"):
print("We've done it bois")
return
get_girlfriend()
but I ...
0
votes
0
answers
41
views
Why a recursion error occurs when implementing the Karachuba algorithm in python
Karachuba algorithm : https://en.wikipedia.org/wiki/Karatsuba_algorithm
threshold = 4
def prod2(a, b):
n = max(len(str(a)), len(str(b)))
if a == 0 or b == 0:
return
elif n <= ...
1
vote
1
answer
131
views
Stop this recursive call once all the items in the items(array) is visited (JavaScript)
I am trying to make a recursion call of this.isParentEmpty() inside this method and I need to stop this recursion once all the items are visited . Maybe using a counter.. Here for example I have items....
0
votes
0
answers
61
views
Infinite recursion of class at initialization
I've been working on a side project in Java in order to become more familiar with threads. It's a cookie clicker clone that uses different threads for the clicker, the counter, and everything else. ...
3
votes
2
answers
171
views
Why doesn't this fixed-point computation stop?
I am new to Haskell, and I have the following code:
second (x:y:xs) = y : second xs -- returns every second element of a list
second _ = []
xs = [1,2,3,4] ++ second xs
I expect xs to be evaluated ...
0
votes
0
answers
47
views
lazy computing of primes with python without recursion error [duplicate]
I came across this great video from computerphile which talked about lazy computing. In the video, they lay out this really beautiful bit of python code that will calculate primes using the sieve ...
1
vote
0
answers
221
views
Infinite call to python class variable
So, I'm fairly new to Python, and I am trying to learn how the OOP paradigm works there.
One thing that confuses me at this stage are the class variables. To be more specific, consider the following ...
0
votes
1
answer
1k
views
Infinite JSON in ManyToMany relationship mapped by Intermediary Table
I have 2 entities that relate to one another. These 2 entities should map to each other in a Many-To-Many relationship, however, I need to also have a timestamp of their respective relationship (when ...
0
votes
1
answer
867
views
cannot run JSF 1.1 application in WebSphere Application Server 8.5.5
I have a war for a JSF 1.1 application built using Sun Java Studio Creator that runs on iPlanet that I have to run on WAS (WebSphere Application Server) 8.5.5. It fails to display welcome page due to ...
1
vote
2
answers
216
views
PHP recursive function not allowing page to load
I am trying to display the total number in each line of a file that does not contain a path to another file as well as the filename,
but if it has a path to another file loop through that file and sum ...
3
votes
0
answers
121
views
Why Java call stack behaves differently according to order of the inputs
I have been doing my homework about recursion and I realized something very strange.
import java.util.Scanner;
public class Recursive{
public static void main ( String [] args){
Scanner ...
1
vote
3
answers
1k
views
Alternative to recursion?
I'm starting to learn Python. Right now I'm creating a CLI that allows to create, view or delete contacts stored in a SQLite 3 DB. The problem is that everytime I finish a task I call the main ...
1
vote
1
answer
293
views
Prolog flatten/2 implementation
Here is my implementation of flatten/2:
flt([], []).
flt([H|L], [H|X]):-
not(is_list(H)),
flt(L, X).
flt([H|L], X):-
append(R, F, X),
flt(H, R),
flt(L, F).
The expected result is ...
0
votes
1
answer
104
views
Why is this code is generating an infinite recursion in SML if it has a base case?
I wrote the following code in SML with the NJ Compiler:
fun all_answers (f, xs) =
let
fun aux(accu, xs_left) =
case xs of
[] => SOME accu
| x::...
-1
votes
1
answer
910
views
Can recursion have an endless loop? [closed]
I hear people say a lot of times recursion can be an “endless loop”, but wouldn’t that saying be only applied to something done with loops. Would it be valid and correct to say “endless loop” for ...
0
votes
0
answers
199
views
Infinite recursion and sys.setrecursionlimit stops script without any errors
I wanted to do a few little experiments via measuring runtimes, especially comparing three implementations of fibonacci: recursive, lru_cache and linear (with linear space). I accidentally implemented ...
1
vote
1
answer
173
views
Out of memory error MATLAB:lang:StackOverflow
I'm developing a Matlab application that works fine uncompiled, but when I compiled it and tried running the executable, got this error :
Out of memory. The likely cause is an infinite recursion ...
2
votes
1
answer
175
views
Compile-time detection of missing user-defined to_string()
I want to provide a to_string(obj) function for every object type I create.
I found this question, applied the accepted answer, and it works. So far so good.
Then I created a new type, but forgot to ...
0
votes
2
answers
75
views
Can't stop recursion, while iterating a template type list
So I have a template type list like this :
template <typename... Types>
struct type_list
{
};
I've made an accessor function like this :
template<class TypeList, size_t ElementIndex>
...