- Notifications
You must be signed in to change notification settings - Fork2
Open
Description
The following helper functions check arrays for all <0, ≤0, 0, ≥0, >0 and ≠0 entries:
// Check if all elements of a non-empty array are zerofunctionArrayIsZero(const A:arrayof Extended): Boolean;begin Assert(Length(A) >0); Result := False;forvar Elemin Adoifnot IsZero(Elem)then Exit; Result := True;end;// Check if all elements of a non-empty array are <> 0functionArrayIsNonZero(const A:arrayof Extended): Boolean;begin Assert(Length(A) >0); Result := False;forvar Elemin Adoif IsZero(Elem)then Exit; Result := True;end;// Check if all elements of a non-empty array are > 0functionArrayIsPositive(const A:arrayof Extended): Boolean;begin Assert(Length(A) >0); Result := False;forvar Elemin Adoif Sign(Elem) <> PositiveValuethen Exit; Result := True;end;// Check if all elements of a non-empty array are < 0functionArrayIsNegative(const A:arrayof Extended): Boolean;begin Assert(Length(A) >0); Result := False;forvar Elemin Adoif Sign(Elem) <> NegativeValuethen Exit; Result := True;end;// Check if all elements of a non-empty array are <= 0functionArrayIsNonPositive(const A:arrayof Extended): Boolean;begin Assert(Length(A) >0); Result := False;forvar Elemin Adoif Sign(Elem) = PositiveValuethen Exit; Result := True;end;// Check if all elements of a non-empty array are >= 0functionArrayIsNonNegative(const A:arrayof Extended): Boolean;begin Assert(Length(A) >0); Result := False;forvar Elemin Adoif Sign(Elem) = NegativeValuethen Exit; Result := True;end;
This issue was extracted from issue#16
Metadata
Metadata
Assignees
Projects
Status
Considering