BartJongejan / Bracmat

Programming language for symbolic computation with unusual combination of pattern matching features: Tree patterns, associative patterns and expressions embedded in patterns.
GNU General Public License v2.0
47 stars 5 forks source link
bignumbers computer-algebra differentiation epoc expression-evaluator gcc high-level-language html json language-technology natural-language-processing pattern-matching programming-language rosettacode semi-structured-data structured-data symbolic-computation tree-structure unstructured-data xml

Bracmat

Bracmat is software for exploration and transformation of uncharted and complex data. Bracmat employs a pattern matching technique that can handle string data (text) as well as structured data (XML, HTML, JSON, algebraic expressions, email, program code, ...).

The programming language construct for pattern matching supports associative pattern matching (known from regular expressions), and expression evaluation during pattern matching (comparable to guards in functional languages). The combination of pattern matching in (semi-)structured data with associative patterns that allow embedded expression evaluation is almost unique.

Bracmat is a good choice for tasks that require dynamic programming.

Since 2023, Bracmat can do floating point calculations. The motivation for implementing the 'UFP' object is the long fancied ability to create illustrations in e.g. SVG or PGM format from within Bracmat code. Therefore its name: 'Unfancyfied Floating Point'.

The only data type in UFP objects is the 64 bit double. UFP objects support multidimensional arrays, do not allow recursion and do not support pattern matching. In short, it is all that regular Bracmat isn't.

More than three hundred examples of Bracmat code can be found at Rosetta Code

This distribution contains the following directories and files:

Usage

Download

You can download Bracmat from GitHub.

mkdir bracmat
cd bracmat
git init
git remote add origin https://github.com/BartJongejan/Bracmat.git
git pull origin master
cd ..

Installation

The Bracmat source code has no other dependencies than what is provided by Standard C. Building bracmat from source is extremely simple, e.g.:

cd singlesource
gcc bracmat.c -lm

or, if bracmat.c does not (yet) exist:

cd singlesource
make

You can also run 'make' in the src directory.

Bracmat requires a C99 compatible compiler since 2023. The older compilers mentioned below will no longer be able to compile Bracmat.

Bracmat has been compiled and run on the following platforms:

If you have plans to run Bracmat from Python, you need Python and Cython besides a C-compiler. The software has been tested on Windows 10, 64 bit, using Cython version 0.28.2 and Python 3.6.3.

Testing

The file valid.bra contains enough tests to get in all corners of the source code, except those that lead to a controled exit condition.

For each error correction and for each new or changed feature a test must be added to valid.bra.

The testsuite valid.bra can also be used to find out how things can be programmed, although there is no good way to quickly search for what you are looking for.

usage: start Bracmat in interactve mode and write

get$"valid.bra"
!r

What others say

From https://chat.stackoverflow.com/transcript/10/2015/10/8/19-20

this programming language Bracmat

& (   !table:? (!country.?len) ?
   & :?N
   & ( @( !arg
        :   ?
            ( %@?c ?
            & ( !c:#
              |   !c:~<A:~>Z
                & asc$!c+-1*asc$A+10:?c
                & 1+!len:?len
              | !c:" "&:?c
              |
              )
            & !N !c:?N
            & ~

beats Perl in terms of line noise

The code cited in this citation can be found in full length here: http://rosettacode.org/wiki/IBAN#Bracmat