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 concatList( ^List source1, source2; ^^List dest; )
	begin
		if source1 == null then
			dest^ = source2;
		else
			dest^ = new( source1.value, null ); 
			concatList( source1.next, source2, &dest^.next );
		end
	end
	
^List source1, source2, a2, a4, a7, a9, dest;
a9 = new( 9, null );
a7 = new( 7, a9 );
a4 = new( 4, null );
a2 = new( 2, a4 );
source1 = a7;
source2 = a2;
concatList( source1, source2, &dest );
printList( source1 );
printList( source2 );
printList( dest );
