with Text_io; procedure BINSRCH is --{by RJBotting, (C) Jan 1992} max_index:constant:=80; NOT_FOUND:exception; --when search fails to find item subtype ITEM is character; subtype INDEX is integer range 1..max_index; type LIST is array (INDEX) of ITEM; type SUBLIST is array(INDEX range <>) of ITEM; --Binary search works by extracting sublists package Index_io is new text_io.Integer_IO(NUM=>INDEX); L:LIST:=(1..max_index=>ASCII.DEL); SIZE:INDEX; procedure GET_LIST(L:out LIST; size:out index) is begin for I in INDEX loop Text_io.get(L(I)); if text_io.end_of_line then size:=I; return; end if; end loop; end GET_LIST; procedure WRITELIST(L:in SUBLIST) is begin for I in L'range loop Text_io.Put(L(I)); end loop; end WRITELIST; function SEARCH(The_table:SUBLIST; TARGET:ITEM) return integer is begin text_io.put("DEBUG:");writelist(The_Table);text_io.new_line; if the_table'length<=1 then if the_table(the_table'first)= Target then return The_table'first; else raise not_FOUND; end if; else declare MID:INDEX:=(the_table'First+The_Table'LAST)/2; begin if the_table(mid)>Target then return search(The_table(the_table'first..Mid-1), Target); elsif the_table(mid) "); Text_IO.GET(Target); text_io.new_line; Index_io.put(search(S, Item(Target) ) ); text_io.new_line; exception when not_found=>text_IO.put("Target not in list"); text_io.new_line; when others=>raise; end; end;