Take the 2-minute tour ×



Syntax::bktmcp: Expression "Hold[?name]]" has no closing "]".



This is exercise 3.2 (page 47) of Power Programming w/ Mathematica

The task is:

"determine the internal representation of the expressions ?name and ??name"

The above is what I tried. It failed. How do I win?

share|improve this question
@term-rewritica - you have Wagner's book? You lucky thing - mine was borrowed by someone years ago and never seen again. –  Verbeia Jul 10 '12 at 7:28
@Verbeia: It's a most intense reading. Reminds me of the first time I read SICP. –  user1602 Jul 10 '12 at 8:21
@Verbeia I do have a copy of that one too (ironically, bought from Amazon fo $40 in 2004, when I just started learning Mathematica as a programming language - and I had no idea about the usefulness of the book at the time, it was a blind purchase). I was lucky to not give it to anyone (well, no one asked). –  Leonid Shifrin Jul 10 '12 at 10:16
@term-rewritica Actually, Roman Maeder's books are more intense reading to me. I think, Wagner wrote his book on just the right level, for someone who knows some Mathematica and wants to bring their M skills to the next level. Can be a little hard to read for a complete beginner, but at least you don't have to read between the lines ( which is what happens all the time with Maeder's books - which is why they are great for experienced users). Wagner's book is still my favorite book on M programming. –  Leonid Shifrin Jul 10 '12 at 10:22
@Leonid: Amazon lists 4 RM books. Do you have a recommendation for order to read them in? –  user1602 Jul 10 '12 at 17:57
show 3 more comments

2 Answers

up vote 18 down vote accepted

To programmatically find the internal representation of the shortforms, you can use MakeExpression, which gives the result wrapped in HoldComplete. Here's an example:

(* HoldComplete[Information["name", LongForm -> False]] *)

(* HoldComplete[Information["name", LongForm -> True]] *)
share|improve this answer
add comment

Here are a couple of alternatives to R.M's method for seeing what Mathematica makes of input.

The input forms of every line entered are stored in the DownValues of In.
Starting with a new session or after using Quit[], evaluating each in a separate Cell:



{HoldPattern[In[1]] :> Information["Mod", LongForm -> False], 
 HoldPattern[In[2]] :> Information["Plus", LongForm -> True], 
 HoldPattern[In[3]] :> DownValues[In]}

Alternatively you could set a $Pre function to echo input:

$Pre = Function[, Print@Unevaluated@#; #, HoldAll];

Information["Plus", LongForm -> False]

x+y+z represents a sum of terms.  >>

share|improve this answer
add comment

Your Answer

