Guest User

Untitled

a guest
Apr 22nd, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ada 0.82 KB | None | 0 0
  1. --  @Parameter:
  2. --    +Str :       String which is searched through
  3. --    +Ch :        Character which is searched in the string 'Str'
  4. --    +Min_Index : The index
  5. --
  6. --  @Return : Returns the Index of the string where the Character --      is located, if it appears in the string
  7. --  --------------------------------------------------------------
  8.  
  9. function Get_Min_Index
  10. (Str : String;
  11. Ch : Character) return Integer is
  12. Counter : Integer := 1;
  13. Min_Index : Integer := Str'First – 1;
  14. begin
  15.    -- Iterate through the String from 'First to
  16.    -- 'Last. If the given Ch is found return its
  17.    -- index.
  18.    if Counter <= Str'Length then
  19.       if Str (Counter) = Ch then
  20.          return Counter;
  21.       end if;
  22.       Counter := Counter + 1;
  23.       return Get_Min_Index (Str, Ch);
  24.    end if;
  25.    return 0;
  26. end Get_Min_Index;
Add Comment
Please, Sign In to add comment