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 appendHead( ^^List a; int data; )
	begin
		a^ = new( data, a^ );
	end

void insertList( ^^List a; int data; )
	begin
		if a^ == null || data <= a^.value 
		then
			appendHead( a, data );
		else
			insertList( &a^.next, data );
		end
	end

^List a5 = new( 5, null );
^List a3 = new( 3, a5 );
^List a1 = new( 1, a3 );
^List a = a1;
insertList( &a, 4 );
printList( a );
