MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

ConstantArray and List

  • To: mathgroup at smc.vnet.net
  • Subject: [mg88156] ConstantArray and List
  • From: Szabolcs Horvát <szhorvat at gmail.com>
  • Date: Sat, 26 Apr 2008 03:46:00 -0400 (EDT)
  • Organization: University of Bergen

Consider the following inputs:

In[1]:= ConstantArray[f[], {5}]

Out[1]= {f[], f[], f[], f[], f[]}

In[2]:= ConstantArray[List[], {5}]

During evaluation of In[2]:= ConstantArray::scalar: Argument {} at \
position 1 is not a scalar. >>

Out[2]= ConstantArray[{}, {5}]


Why doesn't the second one work?  Is this because of the way packed 
arrays are handled (just a guess)?


What is the advantage of ConstantArray over Table or Array?  It doesn't 
seem to be much faster, and it doesn't seem to return an array stored in 
a more efficient way (I experimented a little with MemoryInUse[]).


  • Prev by Date: Re: 3D Arrows
  • Next by Date: Re: 3D Arrows
  • Previous by thread: Re: Coordinate readout from Graphics3D?
  • Next by thread: Re: ConstantArray and List