6
$\begingroup$

The Wolfram Blog article "The Semantic Representation of Pure Mathematics", by Eric Weisstein and Ian Ford (http://blog.wolfram.com/2016/12/22/the-semantic-representation-of-pure-mathematics/) has a Comment by the first author that links to a notebook TopologyEntityStore.nb (https://exploration.open.wolframcloud.com/objects/exploration/TopologyEntityStore.nb).

The first Input cell of that notebook appears like this:

imstore = -;

but if you examine the expression in that cell as text, you see:

Cell[BoxData[
  RowBox[{
    RowBox[{"imstore", "-",
    GraphicsBox[
      TagBox[RasterBox[CompressedData[" ...
....

(many, many lines after that not shown here).

Question: What does that - mean? And how does the expression imstore = - work?

I found no entry CompressedData in the Documentation Center.

$\endgroup$
1
  • $\begingroup$ I think CompressedData is just a front-end way of specifying that an expression should be auto Uncompress-ed when needed. It clearly also behaves in special ways with boxes (compare With[{data = Compress@ArrayReshape[RandomInteger[256, 10000], {100, 100}]}, RawBoxes@RasterBox[CompressedData@data]] with its Uncompress twin. But if you use it as a function there seems to be no difference. $\endgroup$
    – b3m2a1
    Jan 6 '17 at 2:31
9
$\begingroup$

The - is not a character but actually an Image. It is a very clever trick that was used. Each pixel in the image represents an ascii character after a transformation.

Let's review how this image was assembled by an example.

graph = HoldForm[
  Plot[Sin[x], {x, 0, 2 Pi}, PlotLabel -> "Sample Graph"]];
chars = ToCharacterCode[ToString@graph]
(*{80, 108, 111, 116, 91, 83, 105, 110, 91, 120, 93, 44, 32, 123, 120, \
44, 32, 48, 44, 32, 50, 32, 80, 105, 125, 44, 32, 80, 108, 111, 116, \
76, 97, 98, 101, 108, 32, 45, 62, 32, 83, 97, 109, 112, 108, 101, 32, \
71, 114, 97, 112, 104, 93}*)
len = Length[chars];
img = Image[
  Partition[Join[chars, ConstantArray[0, 64 - len]]/65535., 8]]

Mathematica graphics

Now back to an expression

ToExpression[
 FromCharacterCode[
  Take[Flatten[Round[ImageData[img] 65535, 1]], len]]]

Mathematica graphics

$\endgroup$
1
  • $\begingroup$ Why the 64-len there? Exactly what is going on? $\endgroup$
    – murray
    Jan 24 '17 at 1:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.