OKlibrary  0.2.1.6
Order.mac
Go to the documentation of this file.
```00001 /* Oliver Kullmann, 2.6.2009 (Swansea) */
00002 /* Copyright 2009, 2010 Oliver Kullmann
00003 This file is part of the OKlibrary. OKlibrary is free software; you can redistribute
00004 it and/or modify it under the terms of the GNU General Public License as published by
00005 the Free Software Foundation and included in this library; either version 3 of the
00006 License, or any later version. */
00007
00022 oklib_include("OKlib/ComputerAlgebra/DataStructures/Lisp/Lists.mac")\$
00023
00024
00025 /* Lexicographical comparison of lists; returns true
00026    if A is (strictly) less than B lexicographically, and false otherwise.
00027    The elements of A and B must pairwise be comparable by "<".
00028 */
00029 /* Prerequisite: A, B are lists. */
00030 lex_lessp_l(A,B) := orderlessp(A,B)\$
00031 /* The same, but explicitly: */
00032 lex_lessp_l_bydef(A,B) := block([a : length(A), b : length(B), m, res : und],
00033   m : min(a,b),
00034   for p in map("[",take_elements(m,A),take_elements(m,B)) do
00035     if first(p) # second(p) then (
00036       res : is(first(p) < second(p)), return()
00037   ),
00038   if res = und then is(a < b) else res)\$
00039
00040 /* Colexicographical comparison of lists; returns true
00041    if A is (strictly) less than B colexicographically, and false otherwise.
00042    The elements of A and B must pairwise be comparable by "<".
00043 */
00044 /* Prerequisite: A, B are lists with length(A) = length(B). */
00045 colex_lessp_l(A,B) := lex_lessp_l(reverse(A),reverse(B))\$
00046
```