recursive help

Started by
19 comments, last by DarkEldar77 21 years, 5 months ago
quote:Original post by Anonymous Poster
Languages often have specifications and/or "features" such that proper tail-recursion is impossible.

That isn''t the same thing.

That a language may permit one to write programs that are not tail recursive. Even languages that mandate tail recursion-optimizing compilers permit that (transformation into things with manually managed stacks is missing the point entirely).


quote:If compiled with proper tail-recursion in mind, the same function would yield:

If it yielded that, it would yield the wrong answer. Even with "proper" tail recursion, modifying the semantics of the function is wrong.



char a[99999],*p=a;int main(int c,char**V){char*v=c>0?1[V]:(char*)V;if(c>=0)for(;*v&&93!=*v;){62==*v&&++p||60==*v&&--p||43==*v&&++*p||45==*v&&--*p||44==*v&&(*p=getchar())||46==*v&&putchar(*p)||91==*v&&(*p&&main(0,(char**)(--v+2))||(v=(char*)main(-1,(char**)++v)-1));++v;}else for(c=1;c;c+=(91==*v)-(93==*v),++v);return(int)v;}  /*** drpizza@battleaxe.net ***/

This topic is closed to new replies.

Advertisement