String comparison: Difference between revisions

Content added Content deleted
(Lingo added)
Line 33: Line 33:


procedure String_Compare is
procedure String_Compare is

procedure Print_Comparison (A, B: String) is
procedure Print_Comparison (A, B : String) is
use Ada.Text_IO;
Function eq(Left, Right : String) return Boolean
renames Ada.Strings.Equal_Case_Insensitive;
begin
begin
Put_Line
Ada.Text_IO.Put_Line
( """" & A & """ and """ & B & """: " &
('"' & A & """ and """ & B & """: " &
(if A = B then "equal, " elsif eq(A,B)
(if A = B then
"equal, "
then "case-insensitive-equal, " else "not equal at all, ") &
elsif Ada.Strings.Equal_Case_Insensitive (A, B) then
(if A /= B then "/=, " else "") &
"case-insensitive-equal, "
(if A < B then "before, " else "") &
(if A > B then "after, " else "") &
else "not equal at all, ") &
(if A <= B then "<=, " else "(not <=), ") & "and " &
(if A /= B then "/=, " else "") &
(if A >= B then ">=. " else "(not >=).") );
(if A < B then "before, " else "") &
(if A > B then "after, " else "") &
(if A <= B then "<=, " else "(not <=), ") &
(if A >= B then ">=. " else "(not >=)."));
end Print_Comparison;
end Print_Comparison;

begin
begin
Print_Comparison("this", "that");
Print_Comparison ("this", "that");
Print_Comparison("that", "this");
Print_Comparison ("that", "this");
Print_Comparison("THAT", "That");
Print_Comparison ("THAT", "That");
Print_Comparison("this", "This");
Print_Comparison ("this", "This");
Print_Comparison("this", "this");
Print_Comparison ("this", "this");
Print_Comparison("the", "there");
Print_Comparison ("the", "there");
Print_Comparison("there", "the");
Print_Comparison ("there", "the");
end String_Compare;</lang>
end String_Compare;</lang>