Re: newbie myHead question
- To: mathgroup at smc.vnet.net
- Subject: [mg47024] Re: [mg47017] newbie myHead question
- From: Oleksandr Pavlyk <pavlyk at phys.psu.edu>
- Date: Mon, 22 Mar 2004 05:18:33 -0500 (EST)
- Organization: Penn State University; Department of Physics
- References: <200403200850.DAA11433@smc.vnet.net>
- Reply-to: pavlyk at phys.psu.edu
- Sender: owner-wri-mathgroup at wolfram.com
Hi Janos, Since Transpose is undefined on variables with head "myHead" you could first do transpose and then apply Apply[ myHead, Transpose[m] ] or we can define it: Unprotect[Transpose]; Transpose[myHead[args__List]] ^:= myHead @@ Transpose[{args}]; Protect[Transpose]; Then Transpose[ myHead[{a,b},{a,b}] ] gives myHead[ {a,a}, {b,b} ] Best, Sasha János wrote: > I have > > m = {{a, b}, {a, b}, {a, b}} > > When I apply Transpose to it, I will have > > Transpose[m] > > {{a, a, a}, {b, b, b}} > > The FullForm of it is > > List[List[a, a, a], List[b, b, b]] > > Now, if I do > > n = Apply[myHead, m] > > I get > > myHead[{a, b}, {a, b}, {a, b}] > > If I apply Transpose to it, I get > > Transpose[n] > > Transpose[myHead[{a, b}, {a, b}, {a, b}]] > > The FullForm of it > > Transpose[myHead[List[a, b], List[a, b], List[a, b]]] > > which is not that I need. I need > > myHead[{a,a,a},{b,b,b}] > > or > > myHead[List[a, a, a], List[b, b, b]] > > What am I missing ? What should I do to get myHead[{a,a,a},{b,b,b}] ? > > Thanks ahead, > > János
- References:
- newbie myHead question
- From: János <janos.lobb@yale.edu>
- newbie myHead question