Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

11
  • $\begingroup$ +1. I don't know why you dislike the code, it looks pretty good to me. Just one thing - I'd use Cases[Unevaluated[expr], Replace[...],args]. $\endgroup$ Commented Sep 6, 2013 at 6:59
  • $\begingroup$ @Leonid I'm glad it looks good. I guess it just seems like a lot of code for what I think is a rather obvious omission from Cases syntax. Unevaluated[expr] does make sense regarding the name holdCases but it was my intent instead to implement this as if it was a parameter of Cases, just as it is for Level, and Cases does not have HoldFirst. $\endgroup$ Commented Sep 6, 2013 at 7:02
  • $\begingroup$ @Leonid I changed the code somewhat; I think it's easier to read and a bit more efficient. Do you agree/confirm? $\endgroup$ Commented Sep 6, 2013 at 7:22
  • 1
    $\begingroup$ @Mr.Wizard The reason I suggested Unevaluated is that otherwise the expression will evaluate, once passed to heldCases, even when you wrap it in one level of Unevaluated, because there is a rewrite step heldCases to Cases. In other words, when I need to destructure an expression while keeping it unevaluated, I use Cases[Unevaluated[expr],...], while doing the same with heldCases as heldCases[Unevaluated[expr],... won't work with your current code. Re: rewrite - quite nice, I agree. $\endgroup$ Commented Sep 6, 2013 at 10:49
  • 1
    $\begingroup$ @rcollyer x := godObject["rcollyer", "confusticate"] -- meet me in chat ;-) $\endgroup$ Commented Sep 6, 2013 at 12:59