I have a $3\times3$ matrix A
, and a function sTrans
that outputs two $3\times3$ matrices in a list when given a $3\times3$ matrix.
So for the input
A = {{1,2,3} , {4,5,6} , {7,8,9}}
the output is:
sTrans[A]
{ {{3, 1, 2}, {4, 5, 6}, {7, 8, 9}} , {{1, 2, 3}, {6, 4, 5}, {7, 8, 9} }}
And now I want to append the two matrices in a queue. The enQueue operation:
enQueue[q_, elem_] := If[FreeQ[q,elem],qt++; q[[qt]]= elem]
How should I write the code without using loops?
(P.S. I've heard multiple times that the whole concept of MMA is against For
and While
loops)