ianhinder / Kranc

A Mathematica package for generating code for solving time dependent partial differential equations
http://kranccode.org
GNU General Public License v2.0
28 stars 10 forks source link

Make implicit multiply work (i.e. spaces and tabs act as *). #111

Open stevenrbrandt opened 9 years ago

stevenrbrandt commented 9 years ago

This change enables implicit multiplication using spaces and tabs (i.e. not new lines or carriage returns). Thus, if you have a long equation and you wish to have it span multiple lines, you should use an explicit *, e.g.

foo = 3 a b d* e f g

Another side-effect of this change is it makes "to" a keyword (i.e. you can't have a variable named "to"). The reason is that this makes the parameter range impossible to parse. Alternatively, we could use "->" instead of the word "to" in the range specification. While I was making "to" illegal, I also made variables starting with capital D illegal (these names are reserved for derivatives).

stevenrbrandt commented 9 years ago

Note that when parenthesis are present, a * is also needed, otherwise a function call is assumed. Thus

x = 3 a b*(x+y)

Mathematica doesn't have this issue, as function calls use []'s.