Services & Resources / Wolfram Forums / MathGroup Archive

MathGroup Archive 2008

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

Search the Archive

Re: Mapping and AppendTo

  • To: mathgroup at
  • Subject: [mg91758] Re: Mapping and AppendTo
  • From: Albert Retey <awnl at>
  • Date: Sun, 7 Sep 2008 05:37:15 -0400 (EDT)
  • References: <g9qimb$4fg$> <> <g9t6op$jaj$>


> I would like mix use of Map and AppendTo in the following way (e.g.):
> M = {{0,1,2},{4,5,6,7}};
> AppendTo[#,8]&/@M;
> Of course, this doesn't work, because {0,1,2} is not a symbol name,etc.
> Is there a way to use Hold or Sow to make this construct work?

Do you have a good reason to use AppendTo? With Append you just do:

m = {{0,1,2},{4,5,6,7}};
m = Append[#,8]&/@m;

this seems to be more efficient than anything that uses AppendTo as well...



  • Prev by Date: Re: Mapping and AppendTo
  • Next by Date: Re: 3D graphics with NVIDIA GeForce 8400M GS card
  • Previous by thread: Re: Mapping and AppendTo
  • Next by thread: Re: Mapping and AppendTo