functional programming - What is difference between tail recursive and stack recursive functions? -
in pure functional languages, writing factorial function as,
fact.0 = 1 fact.n = n*fact.n-1
as function stack recursive, explain difference between stack recursive , tell recursive functions?
thanks in advance.
the difference between tail recursion , stack recursion (as call it) tail recursive functions can transformed imperative code not use call stack (i.e., while loop), while stack recursion, stack depth proportional recursion depth. mean program overflows stack.
note "transformation imperative code" takes commonly takes place in code generation, output language of compilers assembly, c or other low level imperative language.
note has nothing functional or pure functional languages, have same problem in every language supports recursion. in functional languages, recursion way of looping.
Comments
Post a Comment