Bracmat - the art of failing

Bart Jongejan 2016.01.21

In Bracmat you can't

use types
Data is described by what it looks like, not by its computer internal representation.
use pointers
Data is described by what it looks like, not by its computer internal memory location.
use fixed or floating point numbers
Bracmat implements integers and fractions of indefinite size.
test with 'false' and 'true'
A Bracmat program tests for the success of all its expressions and chooses the next step depending on the result.
subtract and divide
Subtraction is a combination of a multiplication and an addition, division is a combination of exponentiation and multiplication.
use IF condition THEN onething ELSE theotherthing
You do: condition & onething | theotherthing
use regular expressions
Regular expressions tend to be difficult to read when things become complex. And they only take a string as subject, not a list of tuples or a tree. Bracmat patterns are expressive and can take strings as well as tree structured data as subject. In addition, they allow embedded expression evaluation. (This is called "embedded code execution" in Perl.)

In Bracmat you won't

use arrays
You use lists
allocate and deallocate memory
Bracmat does it where needed.
use numbers very much
A number is a poor vehicle for your imagination
normally use quotes or apostrophes around strings
No clutter
use libraries
If you want graphics, sound, internet, numbercrunching or statistics this isn't the right place
have to learn many build-in functions
Three - is that too much? (There are less than 20 built-in functions, of which you mostly use three or four.)
run out of space anytime soon
Bracmat was designed when computer memory was still very precious.
develop programs that are dumb-minded or that run at excessive speeds
Next door
expect that your input is flawless
Bracmat smiles and does not throw exceptions at you

With Bracmat you

analyse data
Such as a large text, old invalid html, your colleague's C++ source or a conversation between your avatar and a software agent
evaluate expressions
So A+A is?
find what you want with a descriptive pattern
That is more clever and more elegant than a regular expression
write programs incrementally
While you learn to break down your data
do difficult things
In an afternoon
have fun
Because it is different

Bracmat

simplifies and normalises algebraic expressions
So that A+A becomes 2*A, so that B+A becomes A+B and so that (A B) C becomes A (B C), which is written as A B C.
evaluates quite advanced algebraic expressions
So that x\D(N^x) becomes N^x*e\LN or
           x
        d N     x  log N
        ---- = N  e
        d x
supports evaluation of expressions in a pattern matching context
So that

(William.McKinley)
(Theodore.Roosevelt)
(William.Howard Taft)
(Woodrow.Wilson)
(Warren "G.". Harding)
(Calvin.Coolidge)
(Herbert.Hoover)
(Franklin "D.". Roosevelt)
(Harry "S.". Truman)
(Dwight "D.". Eisenhower):? (?name1.?surname) ? (?name2.!surname) ?


assigns Theodore to name1 and Franklin D. to name2, because these two presidents have the same surname Roosevelt, and so that

24 25 26 27 28 29:? (?n&!n^1/3:#) ?

assigns 27 to n, because 27 is the first (and only) number in the list that is the cube of an integer.
supports a functional programming style
You are allowed to assign a new value to a variable (change state), but you cannot change the value itself (immutable data).
supports structure sharing
Because of the immutability of values, the same memory location can safely be referenced by conceptually unrelated variables. They will never know of each other's existence.
supports reference counting and automatic deletion
Unreferenced data is at once freed.

Valid XHTML 1.0 Strict