Giter VIP home page Giter VIP logo

bartjongejan / bracmat Goto Github PK

View Code? Open in Web Editor NEW
47.0 6.0 5.0 23 MB

Programming language for symbolic computation with unusual combination of pattern matching features: Tree patterns, associative patterns and expressions embedded in patterns.

License: GNU General Public License v2.0

C 100.00%
pattern-matching semi-structured-data programming-language xml json symbolic-computation language-technology natural-language-processing high-level-language rosettacode

bracmat's People

Contributors

bartjongejan avatar celtic-coder avatar epaul avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

bracmat's Issues

"xmlio" library mentioned on Rosetta Code

Hi Bart (@BartJongejan),

The Create an HTML table task on Rosetta Code makes reference to external library "xmlio.bra", a library that converts from Bracmat format to XML or HTML. I did a search of your repos on GitHub but could not find this file.

Is this a separate library or has its functionality become part of the main Bracmat application?

Kind Regards,
Liam O'Brien

test failure - Unsupported platform (OpenVMS AXP)

Hello,

I compiled bracmat under OpenVMS 8.4 (using the native C compiler).
I ran the test suite and I got 2 errors:

507
550
%DCL-W-IVVERB, unrecognized command verb - check validity and spelling
 \ECHO\
{comment line 1
{com} {comment line 2}
{com} }"sting line 1
{str} string line 2"
{0} ;
tay=
{0}   f,tot,x,fac,cnt,res,R
{0} .   ( R
{1}     =   !cnt:!tot&!res
{1}       |       !res
{1}             +   sub$(!x\D!f:?f.!x.0)
{1}               * (!fac*(!cnt+1:?cnt):?fac)^-1
{1}               * !x^!cnt
{1}           : ?res
{1}         & !R
{1}     )
{0}   & !arg:(?f,?x,?tot)
{0}   & (fac=1)
{0}   & (cnt=0)
{0}   & sub$(!f.!x.0):?res
{0}   & !R;

{0} 
You cannot match an object '=' with '_' if the object is built-in
(out=
.put$!arg:?arg&put$\n&!arg
);
(sgn=
  
.   !arg:#%?arg*%+?&sgn$!arg
  | !arg:<0&-1
  | 1
);
ERROR 724
745
cannot open aaa
747
800
=f,tot,x,fac,cnt,res,R.(R=!cnt:!tot&!res|!res+sub$(!x\D!f:?f.!x.0)*(!fac*(!cnt+1
:?cnt):?fac)^-1*!x^!cnt:?res&!R)&!arg:(?f,?x,?tot)&(fac=1)&(cnt=0)&sub$(!f.!x.0)
:?res&!RERROR 848
850
900
Done. 2 errors. See valid.txt
ok
{!} ok
    S   2982,62 sec  (36486.243606.0)
{?} 
  (36486.243606.0)
{?} )q

I don't know if these are easy to fix, but maybe I could try to do that.
Do you have any indication about these specific errors?

thanks

escape operator's rhs

I am reading Help -> Escaping operator in patterns.
There is a statement:
The escape operator only affects the top node of the escape operator's rhs.
Should it be read as:
The escape operator only affects the top node of the match operator's rhs.
?

There is a qwirk in the imbedded chunk of a license

Hi! Many thanks for your great work. I've just started on the language and it seems to me a great thing. Here is a reference on the line in source code. Not essential, but it says: "PROVIDE THE PROGRAM AS IS WITHOUT WARRANTY OF ANY Child, EITHER EXPRESSED OR IMPLIED".

"PROVIDE THE PROGRAM \\\"AS IS\\\" WITHOUT WARRANTY OF ANY Child, EITHER EXPRESSED\\n"

Comparison to Mathematica's pattern matching capabilities?

I am a nonexpert in this field—but I aspire to one day become one! I am trying to understand the taxonomy and am interested in algorithms for the kinds of matching Mathematica is capable of (and more, e.g. order-sorted matching). Bracmat looks like a fruitful object of study.

The readme lists some of Bracmat's matching features:

  • associative matching
  • matching structured data (tree matching?)
  • match guards

Is Bracmat capable of these other kinds of matching that I am interested in studying?

  • orderless (commutative?) matching
  • matching sequence variables and sequence functions
  • variadic matching (as in [2])
  • flat matching

In [1], Kutsia explains that flat matching is distinct from associative matching. (I have yet to study this paper carefully.) In particular, associative matching is a special case of flat matching. As far as I can tell, flat matching has not received nearly as much attention as associative matching in the literature. I am having a hard time finding implementations of flat matching.

[1] Temur Kutsia, Flat matching, Journal of Symbolic Computation, 2008, vol 43, p. 858–873

[2] Besik Dundua, Temur Kutsia, and Mircea Marin, Variadic equational matching in associative and commutative theories, Journal of Symbolic Computation, vol 106, 2021, p. 78-109

Cannot build bracmat in Ubuntu 22.04

I clone the most current version of this repo, and I tried to build it like this:

$ git clone https://github.com/BartJongejan/Bracmat
Cloning into 'Bracmat'...
remote: Enumerating objects: 3829, done.
remote: Counting objects: 100% (262/262), done.
remote: Compressing objects: 100% (178/178), done.
remote: Total 3829 (delta 148), reused 138 (delta 76), pack-reused 3567
Receiving objects: 100% (3829/3829), 22.84 MiB | 15.19 MiB/s, done.
Resolving deltas: 100% (2689/2689), done.
$ cd Bracmat/singlesource
$ make
cd ../src && make && cd ../singlesource
make[1]: Entering directory '/opt/Bracmat/src'
gcc -std=c99 -pedantic -Wall -O2 -static -DNDEBUG -o bracmat binding.c branch.c builtinmethod.c canonization.c calculation.c charput.c copy.c encoding.c equal.c evaluate.c filestatus.c filewrite.c functions.c globals.c hash.c head.c input.c json.c lambda.c macro.c memory.c nodeutil.c numbercheck.c object.c objectdef.c opt.c position.c potu.c quote.c rational.c result.c simil.c stringmatch.c treematch.c unicaseconv.c unichartypes.c variables.c wipecopy.c writeerr.c xml.c -lm
make[1]: Leaving directory '/opt/Bracmat/src'
../src/bracmat "get'\"one.bra\""
cannot open BRA/potu.c-eliminated.bra
CANNOT-READ potu.c
gcc -std=c99 -pedantic -Wall -O2 -DNDEBUG -o bracmat bracmat.c -lm
cc1: fatal error: bracmat.c: No such file or directory
compilation terminated.

rev function replaces accented characters by question marks.

{?} map$(rev.éléphant)
{!} tnahp??l??
S 0,00 sec (3920.3948)

OS : Macos 11.3.1
Bracmat version : 6.7.4

I've typed the acute accents with both the American keyboard (option-e = é) and the US PC international keyboard ('-e = é), on my Mac. The issue is the same in both cases.

[ prefix

Hello Bart,

I'm analyzing the example in Rosetta Code about arbitraty precision integer.
I was running a different expression based on that one:

@(4^3^2:[ 2 ?)

this should be always true... the position operator ( [ ) is true because is trying to match the 2 char in the string with anything ( ? ). What am I missing here?

JSON to CSV challenge

Hi,

I was interested to employ Bracmat to solve this JSON to CSV challenge.

While I was able to produce the desired result, I was not able to make it fast (the processing time is noticeable). I wonder if I defined the pattern so that it does excessive backtracking:

get$("data.json",JSN) : (, ? (?+(creditcard..?card)+?+(name..?name)+? & out$str$("\"" !name "\", " !card) & ~) ?)

Could you, please, look at this and improve it?

whl problem ?

Hello,
I'm trying to solve a problem from rosetta code about the "names of God the integer".
I used the same logic in the C++ part, but the last while loop seems not working at all.
This is my code

123456:?BIGN;
tbl$(hyp,!BIGN);
(G = n g .
    !arg:(?n,?g)
    & (!g:>!n&0
      |!g:1&1
      |!n+-1*!g:<2&1
      |(!n+-1*!g+-1*2)'!hyp
      )
);
(Ghyp = n f i .
    !arg:?n
    & !BIGN+-2*!n:?f
    & 0:?i 
      & whl'(1+!i:<!f:?i &((!n:1 & 1+G$(!i+!n+1,!n+1):(!n+!i+-1)$?hyp
                            |G$(!i+!n+1,!n+1)+(!n+!i+-1)'!hyp:(!n+!i+-1)$?hyp
                           )
                          )
            )
    & "done"
);
(run = n i .
      1:?i
    & whl'(1+!i:<(!BIGN*2^-1):?i & Ghyp$!i)
    & "done run"
);

I'm quite sure it's my fault, but I cannot understand why if I launch run$, I have nothing in the array hyp.

thanks
Fausto

Can not pass the whole pattern to a function.

To parse a file (hosts file) I created a function. Here is one its line in question:

@(!line:!linePrefix ?host !lineSuffix)

I want lineSuffix to be expanded to a pattern and be passed as an argument. I call it like so:

extract'("mvps.txt","mvps.out",\r\n,1417,"0.0.0.0 ",(" " ?|));

the arguments are captured as:

!arg:(?inFileName, ?outFileName, ?lineSeparator, ?startOffset, ?linePrefix, ?lineSuffix)

And it does not work... It does, if I change the line in question to:

@(!line:!linePrefix ?host (!lineSuffix|))

and the call to:

extract'("mvps.txt","mvps.out",\r\n,1417,"0.0.0.0 ",(" " ?));

effectively splitting the pattern and making a part of it a part of the function.

Supposedly, I do not clearly understand where, at what stage, should I postpone the expansion. I use single quote here and have experimented with = and !!, passed the pattern as a string and tried to escape the |. But no success.

No unicaseconv.c unichartypes.c files in the src folder

During a build from the latest checkout I've got this:

make[1]: Entering directory '/home/roman/lab/aur/bracmat-git/src/Bracmat/src'
make[1]: *** No rule to make target 'unicaseconv.c', needed by 'bracmat'.  Stop.
make[1]: Leaving directory '/home/roman/lab/aur/bracmat-git/src/Bracmat/src'

It seems that files unicaseconv.c unichartypes.c are present in the potu folder, but not in the src folder, while being referenced in the src/Makefile. If I link them from potu to src the build works.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.