$c+
module test15 {  hanoiTowers
 -- test of simple recursion with local variables}
private
 integer From, To, Using, count;
 typedefinition tuple [procedure hanoi()] Towers;
 
 Towers towers;
 
 procedure Towers@hanoi 
        integer holdCount, F,T,U;
        begin
		 holdCount:= count;
		 F := From;
		 T := To;
		 U := Using;
		 if	holdCount = 0 -> skip;	 	
		 []	holdCount > 0 -> 
					count := holdCount -1;
					From := F;
					To	:= U;
					Using := T;
					towers!hanoi();	{ first recursion}
					write 'move from ',F,'	to ',T ;
					count := holdCount-1;
					From := U;
					To	:= T;
					Using := F;
					towers!hanoi();	{ second recursion}
        fi;
        return;
        end;
	

 begin
read count; {  use a small value -- say 4}
From := 1;
To := 2;
Using := 3;
towers!hanoi();
end.
