On 7/19/2010 2:07 AM, David Park wrote:
> I use multiple statements in one cell, with multiple outputs, quite often
> and don't see any problem with it. It's a good way to develop a calculation
> before moving it to a Module, or to develop a derivation or to just try out
> things.
>
> When everything is in one cell you can safely use % and %% without worrying
> about order of evaluation. You can intersperse Print statements if you want
> to annotate the output. You can keep adding further steps and reevaluating
> as a calculation is built up. You can add or remove ";"s as you want to see
> more or less.
Each to his/her own. I personally find student work (and my own work) to
be much easier to follow with one input per cell, or multiple inputs in
a cell separated with semi-colons. As you point out, you can always
intersperse Print statements if you like.
As for % and %%, I never use them, and I certainly don't teach them.
Using % in a single cell vs. multiple cells is a distinction that my
students are likely not to make, with dire consequences. When I first
started teaching with Mathematica ~15 years ago (!), the use of % was
one of the two biggest sources of problems for my students. A couple of
years in, life got much better when I made a conscious decision not to
introduce the % notation to my students, and to discourage its use by
the few students who discover it (or even worse, the dreaded Out[17]
notation, which is a living nightmare) on their own.
When I stopped teaching %, I realized I didn't need it either, and I
stopped using it myself. Nobody misses %, least of all me. I teach my
students to define functions for practically everything, and to assign
names for anything that is not a function if they think they are going
to use it again, or go back and assign a name when needed if they didn't
name it to begin with. If they do that, there is no need for %,
preventing all the problems they used to have with it, and making it
much easier for them (and me, when I have to grade it) to follow their work.
(The other one of the two biggest stumbling blocks in the old days was
students failing to load packages, then remembering after the fact --
when something didn't work -- leading to the Shadowing error, which just
baffled them. I could explain it 100 times, and most of the students
never understood why it was too late once they already tried to use a
function from a package, and never remembered to do it in sequence the
next time. So we started loading commonly used packages right in the
init.m in the classrooms we maintain...which was great, except that the
students would get confused when working somewhere else and completely
forget to load packages. Things got much, much better when most all of
the functionality that we needed from packages was moved to the main
Mathematica. I can't remember the last time I had my students load a
package. Life is good.)
Those two simple things (1) don't teach %, and (2) no more need to load
packages were huge quality-of-life improvements for my classes.
> I never have any problem with Return being misinterpreted as a
> multiplication.
I have seen it happen with student work. Sometimes they do a lot of
copy/paste, and something that looks like a line-break might not be one.
It can be very difficult to trouble-shoot. There is a lot less of this
sort of problem if I teach them to put one input per cell, or separate
with semi-colons if they put multiple inputs within a cell.
> There is a subset of Mathematica users who see writing extended definitions
> and routines as a barrier. The multiple statement, single cell form is a
> good way to transition them to it, because it almost is a routine.
I encourage this all the time with my students, for just that reason,
but have them separate with semi-colons. They don't have any problem
doing that.
--
Helen Read
University of Vermont