This Function is Not Tail Recursive

Tail recursion seems to be an easy concept, but most people get it wrong – including me. Reading the latest German Java SPEKTRUM, I’ve found an article about parallel multicore development by Kornelius Fuhrer. One paragraph was about functional development and tail recursion. First he claims tail recursion makes functions 100% parallizeable (I guess broadly speaking all compositions h(g,f) of side effect free functions g,f are 100% parallizeable in f and g, nothing to do with tail recursion) then he claims his example functions are tail recursive:

Wikipedia says about tail recursion:

In computer science, tail recursion (or tail-end recursion) is a special case of recursion in which any last operation performed by the function is a recursive call, the tail call, or returns a (usually simple) value without recursion.

In all three examples the last operation performed is the multiplication (*), not the function call to itself. First the function itself is called, then the return value is multiplied by n. Stackoverflow has a lot to say about tail recursion too.

A tail recursive version of factorial might look like this:

So please, do not call all functions where the last function call in your source code is a call to itself, tail recursive. A function is tail recursive, if the last operation is a function call to itself.

190 thoughts on “This Function is Not Tail Recursive”

  1. Pingback: frontal
  2. Pingback: hover boards
  3. Pingback: ??? ?????? ??90
  4. Pingback: ??? ?????? ??
  5. Pingback: ??? ?????? ??
  6. Pingback: ??? ????
  7. Pingback: ??? ?????
  8. Pingback: ????? ??????
  9. Pingback: ????? ??? ??????
  10. Pingback: Nike Air Max 90
  11. Pingback: ??? ?????? ??
  12. Pingback: ralph lauren kofta
  13. Pingback: birkenstocks shoes
  14. Pingback: ??? ??????
  15. Pingback: ??? ???? ???
  16. Pingback: ??? ???
  17. Pingback: mbt sandal rea
  18. Pingback: Ray Ban 5150
  19. Pingback: borse gucci prezzi
  20. Pingback: classic handbags
  21. Pingback: sac hermes picotin
  22. Pingback: louboutin coussin
  23. Pingback: handbags purple
  24. Pingback: ?????
  25. Pingback: oakley flak
  26. Pingback: kyrie 2
  27. Pingback: hermes outlet usa
  28. Pingback: cheap nike
  29. Pingback: scarpe nike roshe
  30. Pingback: bayswater mulberry
  31. Pingback: yeezy shoes
  32. Pingback: nba 2k16 mt cheap
  33. Pingback: new
  34. Pingback: useful reference
  35. Pingback: Homepage
  36. Pingback: check over here
  37. Pingback: this content
  38. Pingback: find more info
  39. Pingback: Homepage
  40. Pingback: my company
  41. Pingback: ZCode System
  42. Pingback: see here
  43. Pingback: this page
  44. Pingback: Insta Builder
  45. Pingback: my response
  46. Pingback: directory
  47. Pingback: Clicking Here
  48. Pingback: see this
  49. Pingback: check my site
  50. Pingback: check my site
  51. Pingback: here
  52. Pingback: see this here
  53. Pingback: other
  54. Pingback: original site
  55. Pingback: original site
  56. Pingback: visit
  57. Pingback: my site
  58. Pingback: click here
  59. Pingback: their explanation
  60. Pingback: see this here
  61. Pingback: dig this
  62. Pingback: visit
  63. Pingback: their explanation
  64. Pingback: anchor
  65. Pingback: other
  66. Pingback: 60 day fix
  67. Pingback: 60 day fix
  68. Pingback: click here
  69. Pingback: rims
  70. Pingback: wheels
  71. Pingback: read more
  72. Pingback: read more
  73. Pingback: click here
  74. Pingback: read more
  75. Pingback: read more

Comments are closed.