class List
	begin
		instance
			int value;  
			List next;
			List init( int value; List next; )
				begin
					this.value = value;
					this.next = next;
					return this;
				end
	end

void printList( List a; )
        begin
                print( "{ " );
                while a <> null do
                        print( a.value );
                        a = a.next;
                        if a <> null then
                                print( ", " );
                        end
                end
                print( " }" );
        end

void appendHead( var List a; int data; )
        begin
                a = new List.init( data, a );
        end

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

List a, a1, a3, a5;

a5 = new List.init( 5, null );
a3 = new List.init( 3, a5 );
a1 = new List.init( 1, a3 );
a = a1;
insertList( a, 4 );
printList( a );
println();
