blove
(Betty Love)
1
I’m a newbie and am trying to make multiple copies of a list. For example, if I have the list {1,2,3}, I’d like to do something like
2*{{1,2,3}}
and get
{{1,2,3},{1,2,3}}
I’m looking for functionality similar to this in python:
>>> 2*[[1,2,3]]
[[1, 2, 3], [1, 2, 3]]
Thanks!
wrummler
(William Rummler)
2
ConstantArray should do the trick, and not just for lists but for any expression.
ConstantArray[{1, 2, 3}, 2]
(* Out: {{1, 2, 3}, {1, 2, 3}} *)
http://reference.wolfram.com/mathematica/ref/ConstantArray.html