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 appendList( ^^List a; int data; ) 
	begin
		^List b;
		if a^ == null then
			a^ = new( data, null );
		else
			for b = a^; b.next != null; b = b.next do
			end
			b.next = new( data, null );
		end
	end
	
^List createList( ^int data; int size; ) 
	begin
		^List a = null;
		int i;
		for i = 0; i < size; i++ do
			appendList( &a, data[ i ] );
		end
		return a;
	end
	
int i;
[ 6 ]int a;
int size = 6;
^List b;
a[ 0 ] = 1;
for i = 1; i < size; i++ do
	a[ i ] = 2 * a[ i - 1 ];
end
b = createList( a, size );
printList( b );
