Hacker News new | past | comments | ask | show | jobs | submit login

Is there something that isn't "self-recursion"?



Mutual recursion. Horrible example, don’t use this:

  even 0 = true
  even n = not (odd n-1)
  odd 0 = false
  odd n = not (even n-1)


That should be

  even 0 = true
  even n = odd n-1

  odd 0 = false
  odd n = even n-1
I fed a C version of this (with unsigned n to keep the nasal daemons at bay) to clang and observed that it somehow manages to see through the mutual recursion, generating code that doesn't recurse or loop.


You are correct, I don't know why I put the nots in there. Either way, demonstrates mutual recursion.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: