The latest release of Frink has significant new functionality,
especially for symbolic algebra.
The compiler now tries to perform more symbolic simplification and
optimization of symbolic expressions as they are constructed or
evaluated. For example, the following transformations are now applied:
* Gathering of additive terms:
x + 2x is transformed into 3x.
3x + 4y + 10x is transformed into 13x+4y
* Gathering of multiplicative terms:
5x * 3x^2 is transformed into 15 x^3.
8 x y * 3 x z is transformed into 24 x^2 y z
x / x is transformed into 1.
This allows purely symbolic conversions to be performed. For example:
pack = 10 dog
tribe = 10 pack
tribe / dog
results in:
100
Hint: to avoid "undefined symbol" warnings, call symbolicMode[true]
which suppresses warnings about undefined variables and changes some
behavior when encountering undefined symbols from fail-fast to a more
tolerant deferred evaluation.
Note that at all times, dog is an undefined variable that is
manipulated purely symbolically. Also note that prefix, suffix, and
plural checking is not performed on local variable names, so you can't
write dog or dogs interchangeably like you can if you define a concrete
unit.
In addition, I've been working on facilities that help Frink perform
more general symbolic transformations. Transformation rules can now
contain conditions which must be met before the rule is applied, which
adds a lot of power. For example, the new solvingTransformations.frink
file demonstrates how Frink can be taught to solve many simple algebraic
equations using only a small number of rules:
http://futureboy.us/fsp/colorize.fsp?fileName=solvingTransformations.frink
or
http://tinyurl.com/npw2w7
This is another step toward automatic solution of systems of equations.
As these changes affect almost all programs, please let me know as
soon as possible if you see unexpected results in any program, or if
this affects your algorithms in a negative (or positive!) way.
--
Alan Eliasen
eliasen@...
http://futureboy.us/