Mutual recursion is a case in computer science where multiple problems that depend on each other form a cycle, like the chicken and egg problem.
Questions tagged [mutual-recursion]
104 questions
1
vote
3 answers
Mutual Recursion in Common Lisp
This is the Common Lisp code:
(defun take (L)
(if (null L) nil
(cons (car L) (skip (cdr L)))))
(defun skip (L)
(if (null L) nil
(cons (car L) (take (cdr L)))))
The idea here is that, "take" will give all the odd sequence elements in…

Krishnan Ravikumar
- 295
- 3
- 15
1
vote
3 answers
Practical examples of Mutual Recursion?
I was reading about mutual recursion.In almost all the materials,examples of it was problem to determine whether an integer is even or odd?
int is_even(unsigned int n)
{
if (n==0) return 1;
else return(is_odd(n-1));
}
int is_odd(unsigned…

Rahul Kurup
- 693
- 3
- 9
- 22
1
vote
2 answers
what is a mutually recursive type?
If in ML, an example of a recursive datatype is:
datatype llist = Nil | Node of int * llist
What is a mutually recursive datatype and whats an example of it, in ML?

omega
- 40,311
- 81
- 251
- 474
0
votes
0 answers
Mutual Inclusion of header files and class members c++
I have the following situation:
3 C++ Classes:
ClassA
ClassB
ClassC
class A
{
int member;
B bmember;
};
class B
{
int member;
std::shared_ptr amember;
C cmember;
};
class C
{
int member;
std::shared_ptr …

Mike Rawding
- 121
- 4
0
votes
1 answer
Racket two methods referencing each other
I'm doing exercises from The Little Schemer, but I do them in Racket using DrRacket.
One of the exercises has two methods referencing each other. Can this be done in Racket and if so, how?
When trying to do it in DrRacket ide I get an error because…

Jesper Baltzersen
- 123
- 1
- 6
0
votes
1 answer
Getting tail call optimization in mutual recursion in Scheme
While developing a classical exercise piece of code for odd and even functions in MIT/GNU Scheme (rel 9.2), I encountered a problem that my code does not terminate for a big integer value.
First, I tested the following code, which processes both…

Pavlo Maistrenko
- 187
- 2
- 12
0
votes
1 answer
Racket (Recursive structures and processing templates)
I'm stumped on processing this structure, I want to write a function that tells how many topics occur in a discussion.
; a Discussion is (make-discussion String Digressions)
(define-struct discussion [topic digressions])
; Digressions is [ListOf…

birds_the_word
- 13
- 1
- 4
0
votes
0 answers
Scheduling algorithm in Racket (ASL)
I need to blend aspects of an arbitrary arity tree with generative recursion and backtracking in order to come up with a simple valid schedule.
So far I have two structures, one that identifies the individual with her availability slots and maximum…

Karl
- 1
0
votes
0 answers
How to convert this sequence into MIPS assembly code?
So I've been learning about machine code and assembly language the past few weeks but am somewhat struggling. One of the problems on my assignment asks to convert the listed sequence below into assembly language but I'm just not understanding where…
0
votes
0 answers
Reduce processing time for re.sub() in a nested loop
I am preprocessing a set of files where one file is included in another file with an include tag like shown below:
file A
include file B
include file C
contents of file A
include file D
contents of file A
Here i need to replace the include tags…

Hari Krishnan
- 5,992
- 9
- 37
- 55
0
votes
3 answers
simple javascript function definition problem
function First () {
setTimeout("Second()", 50)
};
function Second () { //I'm very confident this conditional works fine
if (document.getElementsByClassName("l")[0].href ==
document.getElementById("myFrame").getAttribute("src"))
{
…

Devin Rhode
- 23,026
- 8
- 58
- 72
0
votes
1 answer
Memoization with Monad.Memo for mutual recursion in Haskell
I'm doing some dynamic programming in Haskell with mutual recursion implementation.
I decided to speed things up using memoization.
Monad.Memo offers MemoT transformer for that exact case. But it uses Map as internal representation for stored…

aliko
- 319
- 3
- 12
0
votes
1 answer
Racket -> Python
I started learning racket and I'm using arbitrary arity trees and generative recursion to get every possible version of the board from a given board.
So let's say I have this board, where false means empty:
(list "X" "X" "O" "O" "X" "O" "X" #false…

bjj
- 41
- 5
0
votes
3 answers
Mutual recursion between objects in Python
I'm currently working on a module that allows users to build an arbitrary task network model (for use in a discrete event simulation) by creating instances of task objects (my module provides a task class). Among other things, a task contains logic…

mcman
- 35
- 1
- 5
0
votes
0 answers
Analysis of mutual recursion - Luhn algorithm
Luhn algorithm
Used to verify credit card numbers
From the rightmost digit, which is the check digit, moving left, double the value of every second digit; if the product of this doubling operation is greater than 9 (e.g., 8 × 2 = 16), then sum the…

overexchange
- 15,768
- 30
- 152
- 347