/usr/share/axiom-20170501/src/algebra/MTHING.spad is in axiom-source 20170501-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | )abbrev package MTHING MergeThing
++ Description:
++ This package exports tools for merging lists
MergeThing(S) : SIG == CODE where
S : OrderedSet
SIG ==> with
mergeDifference : (List(S),List(S)) -> List(S)
++ mergeDifference(l1,l2) returns a list of elements in l1 not present
++ in l2. Assumes lists are ordered and all x in l2 are also in l1.
CODE ==> add
mergeDifference1: (List S,S,List S) -> List S
mergeDifference(x,y) ==
null x or null y => x
mergeDifference1(x,y.first,y.rest)
x.first=y.first => x.rest
x
mergeDifference1(x,fy,ry) ==
rx := x
while not null rx repeat
rx := rx.rest
frx := rx.first
while fy < frx repeat
null ry => return x
fy := first ry
ry := rest ry
frx = fy =>
x.rest := rx.rest
null ry => return x
fy := ry.first
ry := ry.rest
x := rx
|