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 deleteNode( ^List source; ^^List dest; int value; )
	begin
		if source == null || value < source.value then
			dest^ = source;
		elif value == source.value then
			dest^ = source.next;
		else
			dest^ = new( source.value, null ); 
			deleteNode( source.next, &dest^.next, value );
		end
	end
	
^List source, a2, a4, a6, a8, a10, dest;
a10 = new( 10, null );
a8 = new( 8, a10 );
a6 = new( 6, a8 );
a4 = new( 4, a6 );
a2 = new( 2, a4 );
source = a2;
deleteNode( source, &dest, 6 );
printList( source );
printList( dest );
