[Index for tmp_for_tar/misc]
[Return to Master Index]
lex_cmp
(tmp_for_tar/misc/lex_cmp.m)
Function Synopsis
c = lex_cmp (a, b)
Help text
c = lex_cmp (a, b)
= 1 if a is greater than b for lexicographic order
= -1 if b is greater than a for lexicographic order
= 0 if a and b are equal
Last modified: April 2001
Listing of function file tmp_for_tar/misc/lex_cmp.m
## c = lex_cmp (a, b)
## = 1 if a is greater than b for lexicographic order
## = -1 if b is greater than a for lexicographic order
## = 0 if a and b are equal
##
## Author: Etienne Grossmann <etienne@isr.ist.utl.pt>
## Last modified: April 2001
function c = lex_cmp (a, b)
c = 0 ;
na = prod (size (a)) ;
nb = prod (size (b)) ;
m = min (na, nb) ;
m = find (a(1:m) - b(1:m));
if isempty (m),
if na < nb, c = -1 ;
elseif na > nb, c = 1 ;
end
else
if a(m(1)) < b(m(1)), c = -1 ;
elseif a(m(1)) > b(m(1)), c = 1 ;
end
end
Produced by oct2html on Sat Apr 28 21:14:54 2001
Cross-Directory links are: ON