Author Topic: Michael Haardt's bas BASIC interpreter  (Read 4518 times)

Offline scruss

  • Contributor
  • Posts: 6
    • We saw a Chicken ...
Michael Haardt's bas BASIC interpreter
« on: August 17, 2016, 09:47:41 AM »
Hadn't seen it mentioned here before: : http://www.moria.de/~michael/bas/

It's an easy build, but you'll need to install the flex and bison packages under Raspbian. Note that if you run make check a couple of the tests will fail. These are minor and have been fixed in a pending release.

It's text only, and the dialect is a thoughtful mix of ANSI Full BASIC, BBC BASIC and Microsoft versions. Since it has Full BASIC origins, it implements the matrix functions that the micro versions lost in the 1970s, and many dialects forgot about. You can do things like:

Code: [Select]
REM Solve
REM    x + 2y = 4
REM   3x - 5y = 1
REM by matrix inversion
REM example from
REM  http://www.mathcentre.ac.uk/resources/uploaded/sigma-matrices8-2009-1.pdf
MAT READ a(2,2)
DATA 1,2
DATA 3,-5
MAT READ b(2,1)
DATA 4
DATA 1
PRINT "A:"
MAT PRINT a
PRINT "B:"
MAT PRINT b
MAT a_inv=INV(a)
PRINT "Inverse of A:"
MAT PRINT a_inv
MAT x=a_inv*b
PRINT "Solution:"
MAT PRINT x
END

which prints:

Code: [Select]
A:
 1             2           
 3            -5           
B:
 4           
 1           
Inverse of A:
 0.454545      0.181818     
 0.272727     -0.090909     
Solution:
 2           
 1           
END program