import arraymancer
import sugar
# Create a tensor of value between 0 and 10
var tensor = randomTensor[float](2, 2, 10)
echo tensor
tensor[_, 0] = tensor[_, 0].map(x => x*2)
echo tensor
Run
This is the easiest way I found.
Slicing does not actually create a mutable tensor so this will not work :
# This does not compile
apply_inline(tensor[_, 0]):
x*2
Run
Otherwise, you can also iterate on an axis (see
<https://mratsim.github.io/Arraymancer/accessors.html>)
I'll try to see if I can provide a better example when I have access to my
computer (formatting code on a phone isn't practical).