Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #9049
| From | Dana DeLouis <dana01@me.com> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: Map onto a column |
| Date | 2012-03-15 05:32 +0000 |
| Organization | Steven M. Christensen and Associates, Inc and MathTensor, Inc. |
| Message-ID | <jjrut3$9at$1@smc.vnet.net> (permalink) |
> b = Map[MapAt[f,#,2]&,a]
> b = MapAt[f,a,{All,2}] (...error)
>
> Is there any way to do what I want with a single Map/MapAt function?
Hi. Just another option:
m = {{1,2,3},{4,5,6},{7,8,9}};
m[[All,2]] = f/@m[[All,2]];
// or
m[[All,2]] = Map[f, m[[All,2]]];
m
{{1,f[2],3},{4,f[5],6},{7,f[8],9}}
= = = = = = = = = =
HTH :>)
Dana DeLouis
Mac & Math 8
= = = = = = = = = =
On Mar 13, 4:04 am, Sly Pandemia <slypande...@gmail.com> 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?
Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread
Re: Map onto a column Dana DeLouis <dana01@me.com> - 2012-03-15 05:32 +0000
csiph-web