Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2000
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2000

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

Search the Archive

Re: Lost myHead, please help !!!

  • To: mathgroup at smc.vnet.net
  • Subject: [mg22371] Re: Lost myHead, please help !!!
  • From: "Allan Hayes" <hay at haystack.demon.co.uk>
  • Date: Sat, 26 Feb 2000 22:04:58 -0500 (EST)
  • References: <897drf$5q0@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Antoine:

x = {{a}, {b, c}};

Apply[myHead, x]

myHead[{a}, {b, c}]

Abbreviation for Apply is

myHead @@ x

myHead[{a}, {b, c}]

And we can use ReplaceAll, but with a more discriminating pattern

x /. List[e___] -> myHead[e]

myHead[{a}, {b, c}]

Please note the search for parts to replace is top-down along branches, and
that having replaced {{a},{b,c}} with myHead[{a},{b,c}],no further work is
done on the new part, even though {a} and {b,c} both match List[e___].



"Antoine Zahnd" <antoine.zahnd at iprolink.ch> wrote in message
news:897drf$5q0 at smc.vnet.net...
> Hello everybody,
>
> I can't do the following (sigh)
>
> Let x = {{a},{b,c}}
>
> I would like to tranform it into something like myHead[{a},{b,c}]
>
> Of course x /. {List->myHead} doesn't work !
>
> Certainly it is simple, but so far I didn't get it.
>
> Thank you for your help.
>
> antoine.zahnd at iprolink.ch
>
>
>



  • Prev by Date: Re: Help needed: How to add constraints into FullSimplify
  • Next by Date: RE: Numerical Integration
  • Previous by thread: Re: Lost myHead, please help !!!
  • Next by thread: Using user-defined functions (newbie question)