[metapost] recursion in MP/MF

Dan Luecking luecking at uark.edu
Thu Jan 20 17:43:18 CET 2005


At 11:41 PM 1/19/2005, you wrote:

>But Knuth's simpler example (following) fails
>at about n=60 because  my *input* stack size limit is 60.
>
>%%%% (Knuth)
>def recurse=
>   n:=n+1; message decimal n;
>   %if n< 59: recurse; fi; %% SUCCESS
>   if n< 60: recurse; fi;
>     %% FAILURE LS (OzTeX) input stack size 60
>enddef;

Knuth failed to use tail recursion:
def recurse=
   n:=n+1; message decimal n;
   if n< 6000: expandafter recurse fi
enddef;

This is almost impossible to arrange for the quicksort routine.

Dan


Daniel H. Luecking
Department of Mathematical Sciences
University of Arkansas 



More information about the metapost mailing list