Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1996

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

Search the Archive

Re: Programming: Replace Heads

  • To: mathgroup at
  • Subject: [mg5206] Re: Programming: Replace Heads
  • From: "David B. Wagner" <dbwagner at>
  • Date: Thu, 14 Nov 1996 02:02:10 -0500
  • Organization: Principia Consulting
  • Sender: owner-wri-mathgroup at

Xah Lee wrote:
> I'm delited 2 have the opportunity 2 post another interesting prograMing
> problem.
> Problem:
> Given an abritrary expression, how to replace all heads to List?
> my solution:
> Map[ {(Sequence@@#)}&, expr, {0,-2}]

Much too hard; Apply can be used directly.

    Apply[List, g[a + b, h[c/d]], {0, Infinity}]

    {{a, b}, {{c, {d, -1}}}}

  • Prev by Date: psfix in 2.2
  • Next by Date: Re: Break a List into Individual Elements?
  • Previous by thread: Re: Programming: Replace Heads
  • Next by thread: Re: Programming: Replace Heads