0

I am trying to add derives clause to this procedure and this is my solution :

--# derives Index from Key, Data & Found from Data & I from Data ;

I am not sure about it and I need help

procedure Find
   (Key: Integer ;
    Data : in MyArray ;
    Index : out Integer ;
    Found : out Boolean )
    --# post (Found -> Data(Index) = Key);
    --# derives ???
is
    I: Integer ;
begin
    I := 0;
    Found := False ;
    loop
        --# assert (I >= 0) and
        --# (I <= Data 'Last + 1) and
        --# (Found -> Data(I) = Key);
        exit when (I > Data 'Last ) or Found ;
        if(Data(I)) = Key
        then
            Found := True;
        else
            I:= I + 1;
        end if;
    end loop;
    Index := I;
end Find;
Simon Wright
  • 25,108
  • 2
  • 35
  • 62
Memo
  • 53
  • 6

0 Answers0