MathGroup Archive 2012

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

Search the Archive

Re: Map onto a column


I agree that some solution like that

   b = MapAt[f,a,{All,2}]

would be much more elegant. Maybe in Mathematica 9??

On Mar 14, 2:50 am, Sseziwa Mukasa <muk... at gmail.com> wrote:
> Transpose the matrix and MapAt the appropriate row then Transpose back:
>
> Transpose[MapAt[f,Transpose[a],2]]
>
> On Mar 13, 2012, at 4:02 AM, Sly Pandemia wrote:
>
>
>
>
>
>
>
> > Is there a neat way to map a function onto a specific column in an
> > array?
>
> > For example if I have
>
> > a = {{1,2,3},{4,5,6},{7,8,9}}
>
> > and I want to map f onto the second element in each row. I would
> > normally use
>
> > b = Map[MapAt[f,#,2]&,a]
>
> > but this seems a bit awkward. I would expect to be able to use
>
> > b = MapAt[f,a,{All,2}]
>
> > but this appears to be illegal syntax.
>
> > Is there any way to do what I want with a single Map/MapAt function?




  • Prev by Date: Re: How can I make a sequence that includes lists?
  • Next by Date: Re: How to remove unwanted, garbage plotmarkers
  • Previous by thread: Re: Map onto a column
  • Next by thread: Re: Map onto a column