1
$\begingroup$

I have defined a list like this:

F[1][t] = ConstantArray[a1, 10] 

Now I want to assign to some of the elements the value 1; I try with this:

F[1][t][[2 ;; 4]] = 1 

But I get an error saying that

"F[1][t] in the part assignment is not a symbol"

It seems this happens because Mathematica thinks I want to assign a value to the elements 2 to 4 of [1] which is not a symbol in fact. How can I access to the elements of the list F[1][t] and assign them a value?

$\endgroup$
2
  • 2
    $\begingroup$ You might find something here to help $\endgroup$ Commented Jan 3, 2022 at 15:27
  • 3
    $\begingroup$ You have to set them through a temporary variable: F[1][t] = ConstantArray[a1, 10]; Module[{temp = F[1][t]}, temp[[2 ;; 4]] = 1; F[1][t] = temp; ]; F[1][t] See here $\endgroup$ Commented Jan 3, 2022 at 15:29

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.