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

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -