class List
	begin
		int value;  
		^List next;
	end

int freeNode = 0;
[ 20 ]List nodeHeap;

^List new( int value; ^List next; )
	begin
		^List node = nodeHeap[ freeNode++ ];
		node.value = value;
		node.next = next;
		return node;
	end

void printList( ^List a; ) 
	begin
		printf( "{ " );
		while a != null do
			printf( "%d", a.value );
			a = a.next;
			if a != null then
				printf( ", " );
			end
		end
		printf( " }\n" );
	end
	
void reverseTransferList( ^List source; ^^List dest; )
	begin
		if source != null then
			dest^ = new( source.value, dest^ ); 
			reverseTransferList( source.next, dest );
		end
	end
	
^List source, a2, a4, a7, a9, dest;
a9 = new( 9, null );
a7 = new( 7, a9 );
a4 = new( 4, a7 );
a2 = new( 2, a4 );
source = a2;
reverseTransferList( source, &dest );
printList( source );
printList( dest );
