My main project for this past week was to add speech synthesis
capabilities to the automated video demonstration system I am
creating. Here is a video that contains a synthesized speech
description of how to use MathPiperIDE worksheets:
https://youtu.be/eGldEkSczs4
ASSIGNMENT 2
1) Watch the above video.
2) Download version .149 of the “Introduction to Programming with
MathPiper and MathPiperIDE” book:
http://patternmatics.org/mathpiper/developer_releases/
3) Read section 8.4.1 “Rectangular Selection Mode” that starts on line 883.
4) Read section 9. Create a new .mpw worksheet file named
“section_9_examples.mpw” and save it. Copy some of the example folds
this section contains into the new worksheet, and evaluate them by
placing the cursor inside each fold and pressing <shift><enter>.
5) After you have evaluated some folds, notice that a file named
“section_9_examples.mpwlog” has been created in the same directory
that “section_9_examples.mpw” is in. Open this log file inside of
MathPiperIDE and look at it. A copy of the code that is in a fold when
it is evaluated is placed into this log file each time a fold is
evaluated.
6) Copy the following fold into the bottom of the worksheet and evaluate it:
%mathpiper
ViewList('(5 + 6*21/7 - 2^3));
Show(TreeView('(5 + 6*21/7 - 2^3)));
UnparseLisp('(5 + 6*21/7 - 2^3));
%/mathpiper
Two windows will be displayed, one directly over the top of the other.
Move the top window to the side. Compare the diagrams that these two
windows contain with each other and with the code that was returned as
the fold’s side effect output.
Both of the diagrams contain equivalent and completely unambiguous
representations of the relationships that exist between all of the
operators and operands in the given mathematical expression . If you
were ever curious about the programming language Lisp, the diagram
produced by ViewList and the code displayed in the side effect output
will give you some clues about its nature.
7) Enable the “Show Positions” checkbox that is at the bottom of the
tree diagram. The positions that are shown are used to navigate to
different nodes in the tree starting from the root node (which is the
topmost node). For example, the / operator is at position “122”, and
the 3 is at position “22”. Can you see how these positions can also be
used to navigate the list diagram of the expression?
8) Copy the following fold into the bottom of the worksheet, and evaluate it:
%mathpiper
code := ''{
a := 1;
Echo(a);
b := 2;
Echo(b);
c := 3;
Echo(c);
};
ViewList(code);
Show(TreeView(code));
code;
%/mathpiper
The '' operator is called the “freeze” operator. It is similar to the
' “hold” operator, but the hold operator only holds its operand for
one evaluation while the freeze operator holds its operand
indefinitely.
Separate the two windows that are shown, and compare their contents
with each other and with the diagrams that were produced for the
mathematical expression by the previous fold. You should notice that
mathematical expressions and programming code expressions are
represented using the same tree/list mechanism. I think students of
all ages would think this information is very interesting.
9) One last example fold just for fun :-)
%mathpiper,output="flowchart"
{
a := 1;
Echo(a);
b := 2;
Echo(b);
c := 3;
Echo(c);
};
%/mathpiper
If you have any questions, comments, or bug reports, please submit
them to the Math Future group.
Ted