I guess this is rather trivial. Given, e.g.,
L={1,2}
what are some common efficient ways to obtain
L
(*{1,2,1,2,1,2}*)
that is, the list concatenated three times with itself and obtained the new value. Thanks in advance.
I guess this is rather trivial. Given, e.g.,
L={1,2}
what are some common efficient ways to obtain
L
(*{1,2,1,2,1,2}*)
that is, the list concatenated three times with itself and obtained the new value. Thanks in advance.
There is a dedicated function in R:
Needs["RLink`"]
InstallR[]
REvaluate["rep(c(1,2),5)"]
(* {1., 2., 1., 2., 1., 2., 1., 2., 1., 2.} *)
Another possibility is to use length.out:
REvaluate["rep(c(1,2),length.out=5)"]
(* {1., 2., 1., 2., 1.} *)
Catenate@ConstantArray[L, 3]? – Szabolcs Apr 04 '17 at 19:59ArrayPad[{1, 2}, 2, "Periodic"]– Kuba Apr 04 '17 at 20:053*Lto get the desired output:-)! – Dimitris Apr 05 '17 at 20:13