I am trying to append to a list which starts out empty and accumulates elements if some conditional logic in the function is met. The problem is that when trying to add the first element to the list I get a "List { } and { with my entry} are not the same shape. Here is an example:
checkForAs[aList_,element_,myAccList_]:= Module[{resultValue},
If[Length[StringCases[ToString[aList],element]]>0,resultValue=aList, resultValue={}];
resultValue;
myAccList = Append[myAccList,resultValue]
]
myAccList = {};
testList = {{b,b,b,b,c,b,b},{a,c,b,b,c,c,c},{b,b,b,b,b,c,c,a,b,b,b,c,c},{c,c,c,c,c,b,b},{a,b,b,b,b,c}};
checkForAs[testList[[1]],"a",myAccList]
checkForAs[testList[[2]],"a",myAccList]
Out[477]= {{}} Set::shape: Lists {} and {{}} are not the same shape. >> Out[478]= {{a, c, b, b, c, c, c}} Set::shape: Lists {} and {{a,c,b,b,c,c,c}} are not the same shape. >>