# Re: [fricas-devel] Algebraic Topology Issue 1

```AFAICS the attached patch fixes the problem:

--
Waldek Hebisch```
```
--
You received this message because you are subscribed to the Google Groups
"FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email
To post to this group, send email to fricas-devel@googlegroups.com.
```
```--- ../ax-build195/src/algebra/SIMPC.spad       2016-09-19 22:51:14.843152617
+0000
@@ -247,7 +247,7 @@
reslt := concat(reslt, orderedPermutation(rst, len))
reslt

-   -- local function used in listUnion in addImpliedFaces
+   -- local function used in unorientedUnion in addImpliedFaces
isNewFace?(lst : List(OrientedFacet), b : OrientedFacet) : Boolean ==
--print("isNewFace?(" << a << ", " << b << ")")
for a in lst repeat
@@ -256,17 +256,17 @@
true

-- local function used in addImpliedFaces
-   listUnion(a : List(OrientedFacet), b : List(OrientedFacet)
+   unorientedUnion(a : List(OrientedFacet), b : List(OrientedFacet)
) : List(OrientedFacet) ==
-       res := []\$List(OrientedFacet)
-       for a1 in a repeat
-           res := concat(res, a1)
+       res := a
for b1 in b repeat
if isNewFace?(a, b1) then
-               res := concat(res, b1)
-       --print("listUnion(" << a << ", " << b << ") = " << res)
+               res := cons(b1, res)
+       -- print("unorientedUnion(" << a << ", " << b << ") = " << res)
res

+   import from OutputForm
+
-- A function to take a set of faces and add those that are implied
-- by the simplicial complex conventions (if they don't already exist).
-- For example, if the input is a triangle ((1, 2, 3)) then we would add
@@ -280,27 +280,29 @@
return res
-- create an empty list for each grade
-       for a in 1..(maxGrade) repeat
-           res := concat(res, []\$List(OrientedFacet))
+       res := []\$List(List(OrientedFacet))
newFaces := []\$List(OrientedFacet)
-       for gr in inputList for grn in 1..(maxGrade) repeat
+       for gr in inputList repeat
-           for face in gr repeat
-               res.grn := concat(res.grn, face)
-           for face in newFaces repeat
-               res.grn := concat(res.grn, face)
+           all_faces := unorientedUnion(newFaces, gr)
+           -- print(message("all_faces = "))
+           -- print(all_faces::OutputForm)
+           res := cons(all_faces, res)
--print("addImpliedFaces empty newFaces. res.grn=" << res.grn)
-           newFaces := []\$List(OrientedFacet)
+           newFaces := []
-           for face in res.grn repeat
+           for face in all_faces repeat
+               -- FIXME: handle order 1 too
len : NNI := (order(face) -1) pretend NNI
if len > 0 then
-                   newFaces := listUnion(newFaces, allSubsets(face, len, len))
+                   newFaces := unorientedUnion(newFaces,
+                                               allSubsets(face, len, len))
+           -- print(message("newFaces = "))
+           -- print(newFaces::OutputForm)