$ TADA/LIST=TSTSHELLI TSTSHELLI TeleSoft-Ada compiler -- Version 1.3d March 25, 1983 Copyright (c) 1981,1982,1983 TeleSoft. All rights reserved. Opening tstshelli.text Symbol table space: 127.5K bytes Compilation complete Syntax errors: 0 Semantic errors: 0 Lines compiled: 75 reset(tstshelli.CODE) rewrite(tstshelli.CODE) Segment 1, 3 procedures ... end. $ TRUN TSTSHELLI RAW DATA MMM 1.0000000E+00 NNN 2.0000000E+00 AAA 3.0000000E+00 CCC 4.0000000E+00 BBB 5.0000000E+00 ZZZ 6.0000000E+00 XXX 7.0000000E+00 PPP 8.0000000E+00 QQQ 9.0000000E+00 SORTED AAA 3.0000000E+00 BBB 5.0000000E+00 CCC 4.0000000E+00 MMM 1.0000000E+00 NNN 2.0000000E+00 PPP 8.0000000E+00 QQQ 9.0000000E+00 XXX 7.0000000E+00 ZZZ 6.0000000E+00 $ TYPE TSTSHELLI Opening tstshelli.text 1: with TEXT_IO ; use TEXT_IO, INTEGER_IO, FLOAT_IO ; 2: 3: procedure MAIN is 4: 5: subtype NAMES is STRING(1..3) ; 6: -- create user defined type A_NAMES (note: the box <> means 7: -- to be filled in later) 8: type A_NAMES is array( INTEGER range <> ) of NAMES ; 9: -- create object ACCOUNT_NAMES with indicies 1..9, and initialize 10: ACCOUNT_NAMES : A_NAMES ( 1..9 ) := 11: ( "MMM","NNN","AAA","CCC","BBB","ZZZ","XXX","PPP","QQQ" ) ; 12: 13: -- create user defined type A_BALANCES 14: type A_BALANCES is array( INTEGER range <> ) of FLOAT ; 15: -- create object BALANCES with indicies 1..9, and initialize 16: BALANCES : A_BALANCES ( 1..9 ) := 17: ( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 ) ; 18: OPEN_ACCOUNTS : INTEGER := 9 ; 19: 20: procedure PRINT_ACCOUNTS is 21: begin 22: for I in 1..OPEN_ACCOUNTS loop 23: PUT(ACCOUNT_NAMES(I));PUT(BALANCES(I));PUT_LINE(""); 24: end loop ; 25: end PRINT_ACCOUNTS ; 26: 27: 28: procedure SHELLI( SIZE : in INTEGER ; 29: ARR1 : in out A_NAMES ; 30: ARR2 : in out A_BALANCES ) is 31: 32: M,I,J,LIMIT : INTEGER ; 33: TEMP2 : FLOAT ; 34: TEMP1 : NAMES ; 35: 36: begin 37: M := SIZE ; 38: while M > 1 loop -- log base 2 of SIZE times 39: M := M / 2 ; -- through this loop 40: LIMIT := SIZE - M ; 41: for J in 1..LIMIT loop -- at most SIZE times 42: I := J ; -- through this loop 43: 44: while I > 0 loop -- this loop depends on data, 45: -- statistically about 2.5 46: -- times through this loop 47: 48: -- compare on whatever is being sorted 49: if ARR1(I) >= ARR1(I+M) then 50: -- interchange, 3 statements for each array 51: -- being sorted 52: TEMP1 := ARR1(I) ; 53: ARR1(I) := ARR1(I+M) ; 54: ARR1(I+M) := TEMP1 ; 55: TEMP2 := ARR2(I) ; 56: ARR2(I) := ARR2(I+M) ; 57: ARR2(I+M) := TEMP2 ; 58: I := I - M ; -- must check previous entry 59: else 60: exit ; -- while I > 0 , previous entries sorted 61: end if ; 62: end loop ; -- on while I > 0 63: end loop ; -- on for J in 1..LIMIT 64: end loop ; -- on while M > 1 65: end SHELLI ; -- return from procedure 66: 67: begin 68: 69: PUT_LINE(" RAW DATA ") ; 70: PRINT_ACCOUNTS ; -- print unsorted data 71: SHELLI(OPEN_ACCOUNTS,ACCOUNT_NAMES,BALANCES) ; -- call the sort 72: PUT_LINE(" SORTED ") ; 73: PRINT_ACCOUNTS ; -- print sorted data 74: 75: end MAIN ; Compilation complete Syntax errors: 0 Semantic errors: 0 Lines compiled: 75 The file TSTSHELLI.COM contained these three lines: $ TADA/LIST=TSTSHELLI TSTSHELLI $ TRUN TSTSHELLI $ TYPE TSTSHELLI The command line $ TSTSHELLI/OUT=TSTSHELLI.PRT was typed, followed by: $ PRINT TSTSHELLI.PRT (after a little editing)