TransWikia.com

How to write this piece of code without AppendTo

Mathematica Asked on December 28, 2021

I am trying to fill a vector starting from component 11 from another vector, I use this code:

Do[AppendTo[xp, x[[i + 10]]], {i, 1, 99982}]

How can I fill xp without using `AppendTo’?

One Answer

If you want xp just to be the values of x from component 11 you can use xp = x[[11;;]]. If xp is already defined, has some values and you want to append the values of x, starting from component 11 then Join[ xp , x[[11;;]] ] should do the trick.

Answered by Gert on December 28, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP