Order two numerical lists: Difference between revisions

Add Seed7 example
m (→‎{{header|REXX}}: added whitespace to section comment, changed font for a language. -- ~~~~)
(Add Seed7 example)
Line 866:
((= (car a) (car b)) (lex<? (cdr a) (cdr b)))
(else (< (car a) (car b)))))</lang>
 
 
=={{header|Seed7}}==
The operator corresponding to the ordering described in this example is less than.
 
<lang seed7>$ include "seed7_05.s7i";
 
const proc: main is func
begin
writeln([] (1) < [] (1, 2)); # If the first list runs out of elements the result is TRUE.
writeln([] (1, 2) < [] (1)); # If the second list runs out of elements the result is FALSE.
writeln([] (1, 2) < [] (1, 2)); # If both lists run out of elements the result is FALSE.
writeln([] (1, 2, 3) < [] (1, 1, 3)); # The second element is greater than --> FALSE
writeln([] (1, 2, 3) < [] (1, 3, 3)); # The second element is less than --> TRUE
writeln(0 times 0 < [] (1)); # The empty list is less than any nonempty list --> TRUE
writeln([] (1) < 0 times 0); # Any nonempty list is not less than the empty list --> FALSE
writeln(0 times 0 < 0 times 0); # The empty list is not less than the empty list --> FALSE
end func;</lang>
 
{{out}}
<pre>
TRUE
FALSE
FALSE
FALSE
TRUE
TRUE
FALSE
FALSE
</pre>
 
=={{header|Standard ML}}==