0

I am kind of new to mathematica and have done earlier programming in C,C++, Java and most recently MATLAB. This is why i am facing some issues in understanding the syntax. I just wish to add an element to a list inside a Module. The element is not a number and so AppendTo is not working. When i try to use Append as in : a = Append[a,g1a] where a is the list and g1a is the element which i wish to insert, it gives a

"Lists {p,q} and {p,q,g1a,g1b} are not the same shape." error.

I looked at some posts and they suggest using Hold attributes but I am not able to understand the logic that is going behind and how I should implement it. The code is :

function[list_]:= Module[{i},

For[i=1,i<= 3,i++, 
       list = Append[list, Symbol["g" <> ToString[i] <> "b"]];
]

Any suggestions will be greatly appreciated.

Kuba
  • 136,707
  • 13
  • 279
  • 740
Abhishek Pal
  • 365
  • 1
  • 9

0 Answers0