scala - Is 'def eat():Unit = sleep(); def sleep(): Unit = eat()' a tail recursive function? -


two functions:

def eat(): unit = sleep() def sleep(): unit = eat() 

both of them recursive functions, because called in body (indirectly), right?

but tail recursive functions?

both of them recursive functions, because called in body (indirectly), right?

yes, called mutual recursion.

but tail recursive functions?

yes, are, call return value of body. however, afaik scala compiler not optimise these while loops, self-recursive functions. see does scala support tail recursion optimization? details, , how use tailcalls? workaround.


Comments

Popular posts from this blog

javascript - How to process users in one specific order using map o each function? -

java - Two interface have same method name with different return type -

javascript - Linking from page A to a specific iframe on page B -