with Ada.Text_IO; use Ada.Text_IO; with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; procedure wordCount is type B_Str is record chars: String(1..37); length: Natural; end record; procedure put(bw: B_Str) is begin put(bw.chars(1..bw.length)); end put; -- we'll need to compare two bounded strings; we want -- ("cat_xyz..",3) = ("cat_zzz..",3) -- but the built-in/default `=` for records would compare all 37chars. -- function "="(left, right: B_Str) return Boolean is begin return left.chars(1..left.length) = right.chars(1..right.length); end "="; function get_B_Str( dummy: Natural ) return B_Str is result: B_Str; begin get_line( result.chars, result.length ); return result; end get_B_Str; type oneThousandBoundedStrings is array(1..1000) of B_Str; type Word_List is record words: oneThousandBoundedStrings; length: Natural := 0; end record; procedure put(wrdz: Word_List) is begin for i in 1..wrdz.length loop put(wrdz.words(i)); end loop; end put; procedure add( wordz: in out Word_List; word: B_Str ) is begin wordz.length := wordz.length + 1; wordz.words(wordz.length) := word; end add; -- firstOccurrenceAt(i: Natural; wrd: B_Str; wrdz: Word_List): -- is wrdz(i)=wrd, wrdz(j) /= wrd for all 1<=j