Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
25
Task/String-comparison/Seed7/string-comparison-1.seed7
Normal file
25
Task/String-comparison/Seed7/string-comparison-1.seed7
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
$ include "seed7_05.s7i";
|
||||
|
||||
const proc: showComparisons (in string: a, in string: b) is func
|
||||
begin
|
||||
writeln("compare " <& literal(a) <& " with " <& literal(b) <&":");
|
||||
writeln("a = b returns: " <& a = b);
|
||||
writeln("a <> b returns: " <& a <> b);
|
||||
writeln("a < b returns: " <& a < b);
|
||||
writeln("a > b returns: " <& a > b);
|
||||
writeln("a <= b returns: " <& a <= b);
|
||||
writeln("a >= b returns: " <& a >= b);
|
||||
writeln("compare(a, b) returns: " <& compare(a, b));
|
||||
writeln("compare(lower(a), lower(b)) returns: " <& compare(a, b));
|
||||
end func;
|
||||
|
||||
const proc: main is func
|
||||
begin
|
||||
showComparisons("this", "that");
|
||||
showComparisons("that", "this");
|
||||
showComparisons("THAT", "That");
|
||||
showComparisons("this", "This");
|
||||
showComparisons("this", "this");
|
||||
showComparisons("the", "there");
|
||||
showComparisons("there", "the");
|
||||
end func;
|
||||
35
Task/String-comparison/Seed7/string-comparison-2.seed7
Normal file
35
Task/String-comparison/Seed7/string-comparison-2.seed7
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
include "scanstri.s7i";
|
||||
|
||||
const func integer: cmpNumeric (in var string: stri1, in var string: stri2) is func
|
||||
result
|
||||
var integer: signumValue is 0;
|
||||
local
|
||||
var string: part1 is "";
|
||||
var string: part2 is "";
|
||||
begin
|
||||
while signumValue = 0 and (stri1 <> "" or stri2 <> "") do
|
||||
part1 := getDigits(stri1);
|
||||
part2 := getDigits(stri2);
|
||||
if part1 <> "" and part2 <> "" then
|
||||
signumValue := compare(part1 lpad0 length(part2), part2 lpad0 length(part1));
|
||||
if signumValue = 0 then
|
||||
signumValue := compare(length(part1), length(part2));
|
||||
end if;
|
||||
elsif part1 <> "" then
|
||||
signumValue := compare(part1, stri2);
|
||||
elsif part2 <> "" then
|
||||
signumValue := compare(stri1, part2);
|
||||
end if;
|
||||
if signumValue = 0 then
|
||||
part1 := getNonDigits(stri1);
|
||||
part2 := getNonDigits(stri2);
|
||||
if part1 <> "" and part2 <> "" then
|
||||
signumValue := compare(part1, part2);
|
||||
elsif part1 <> "" then
|
||||
signumValue := compare(part1, stri2);
|
||||
elsif part2 <> "" then
|
||||
signumValue := compare(stri1, part2);
|
||||
end if;
|
||||
end if;
|
||||
end while;
|
||||
end func;
|
||||
Loading…
Add table
Add a link
Reference in a new issue