I have a procedure in Maple. Input is a list. The procedure should add to a list the list [6,5,4,3,2,1] and find if there are repetitions in this new list. After, if there are repetitions, it should return [NO, initial list] and if there are no repetitions, it should find how many elements of the first 5 are larger than the 6th element and return this number together with the sorted list - [6,5,4,3,2,1] in reverse order. (It sounds a bit strange but it's actually computing some sheaf cohomologies).
The problem is, when there are repetitions, the procedure returns an array, and if there are no repetitions, it returns exprseq. I would like both to be an array. Where's the mistake?
For example, coh([4, 0, 0, 0, 0, 4]) is an array and coh([0, 0, 0, 0, 0, 12]) is exprseq.
Here's the text of the program:
coh := proc (L::list)
Hm := Array([0, 0]);
b := 0;
M := L+[6, 5, 4, 3, 2, 1];
a := evalb(ListTools:-FindRepetitions(M) = );
if a = false then Hm := Array(['NO', L]) else
for i to 5 do if M[i] < M then b := b+1
K := sort(M);
KK := K+[-1, -2, -3, -4, -5, -6];
for j to n do
M[j] := KK[n-j+1]
Hm := b;
Hm := M;