MathGroup Archive 1996

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

Search the Archive

Programming: Replace Heads

  • To: mathgroup at
  • Subject: [mg5161] Programming: Replace Heads
  • From: Xah Lee <xah at>
  • Date: Wed, 6 Nov 1996 01:34:08 -0500
  • Organization: Best Internet Communications
  • Sender: owner-wri-mathgroup at

I'm delited 2 have the opportunity 2 post another interesting prograMing 

Given an abritrary expression, how to replace all heads to List?

my solution:
Map[ {(Sequence@@#)}&, expr, {0,-2}]



f := ({a,b,c,d,e,g}[[Random[Integer, {1,6}] ]])

Array[ Hold at f, {3,2,3},1, Hold at f]//ReleaseHold

Map[ {(Sequence@@#)}&, %, {0,-2}]

Post your solutions. Please cc to me 2. I will write up a summary of 
solutions of PrograMMing Competition of last month.

 xah at; 74631.731 at
 Mountain View, CA, USA

  • Prev by Date: Re: mathematica 3.0 comments?
  • Next by Date: Re: simplify problem
  • Previous by thread: Re: PDE-Solving in Mathematica
  • Next by thread: Re: Programming: Replace Heads