Skip to content

Instantly share code, notes, and snippets.

@rebcabin
Created April 5, 2012 20:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rebcabin/2313720 to your computer and use it in GitHub Desktop.
Save rebcabin/2313720 to your computer and use it in GitHub Desktop.
Much better quoting
SetAttributes[captive2, HoldAllComplete];
captive2[expr_ /; NumberQ @ Unevaluated @ expr] := number2[ToString[expr]]
captive2[expr_ /; (Head @ Unevaluated @ expr === Symbol)] := symbol2[ToString @ Unevaluated @ expr]
captive2[expr_ /; (Head @ Unevaluated @ expr === String)] := string2["\"" <> expr <> "\""]
captive2[head_[args___]] := {captive2 @ head, captive2 /@ Unevaluated @ {args}}
captive2[x___] := Throw @ {x};
@rebcabin
Copy link
Author

rebcabin commented Apr 5, 2012

an application of this facility appears in https://gist.github.com/2313759

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment