Questions tagged [infinite-recursion]

An infinite recursion occurs when one or several recursive methods keep on calling each other and never reaching a terminal case. Such a situation will most likely end up in the call stack to overflow.

An infinite recursion occurs when one or several recursive methods keep on calling each other and never reaching a terminal case. Such a situation will most likely end up in the call stack to overflow.

64 questions
15
votes
3 answers

Spring Data JPA - bidirectional relation with infinite recursion

First, here are my entities. Player : @Entity @JsonIdentityInfo(generator=ObjectIdGenerators.UUIDGenerator.class, property="id") public class Player { // other fields @ManyToOne @JoinColumn(name = "pla_fk_n_teamId") private Team…
Mickaël Bénès
  • 147
  • 1
  • 2
  • 7
10
votes
3 answers

What is the mathematical significance of "all (==1) [1,1..]" not terminating?

Intuitively, I would expect the "mathematical" answer to all (==1) [1,1..] to be True because all of the elements in a list that only contains 1s are equal to 1. However I understand that "computationally", the process of evaluating the infinite…
4
votes
5 answers
3
votes
2 answers

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 to [1,2,3,4,2,4,4], because that is the fixed…
3
votes
0 answers

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 scan = new Scanner(System.in); …
asimtot
  • 63
  • 1
  • 6
2
votes
2 answers

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 Exception { int n = 3; int k = 2; int result =…
2
votes
1 answer

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 write a to_string() for it (or better: I…
2
votes
1 answer

Infinite recursion for parsing arithmetic expressions using a recursive descent parser

I am trying to create my own recursive descent parser in python, but when my parser runs into a rule concerning arithmetic expressions, it surpasses the python recursion limit. Here is the grammar: Term --> Factor {( "+" | "-" ) Factor} Factor -->…
Monolith
  • 1,067
  • 1
  • 13
  • 29
2
votes
1 answer

Implementation of `first` in Arrow library

I don't understand the implementation of first in the library. first seems to be defined recursively with *** -- I don't see when the recursion shall end!? first :: a b c -> a (b,d) (c,d) first = (*** id) and (***) :: a b c -> a b' c' -> a (b,b')…
2
votes
0 answers

Infinite recursion (StackOverflowError) in Amazon EMR cluster

We are running a Spark App on an Amazon EMR cluster. Our code takes in JSON data, converts it to dataframes, carries out Spark SQL transformations on them and then writes the resulting dataframes to csv files (at least, it tries to). However, when…
2
votes
1 answer

Error: evaluation nested too deeply: infinite recursion / options(expressions=)? in R3.3.2

I'm trying to use a function in order to read in different models. Using the code below without a function works. When I use the function and call it, I will get the error Error: evaluation nested too deeply: infinite recursion /…
scriptgirl_3000
  • 161
  • 3
  • 16
1
vote
1 answer

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 fields where the user can input the number to get the exchange rate as shown here: Screenshot of Component The fields are as follows: <>
Amrut Wali
  • 13
  • 3
1
vote
4 answers

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 formula, I thought it would be an interesting…
1
vote
3 answers

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 following: E[f(b,r)] =…
nyan314sn
  • 1,766
  • 3
  • 17
  • 29
1
vote
2 answers

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 object to a third object, but to do such I need to…
GreenChild
  • 13
  • 3
1
2 3 4 5