Hello, Lawrence:
I can't for the life of me remember if you're the moderator here.... ;)
Anyway, I have some Public Domain code that I want to POSTIT! here,
since I just ported it over to PowerBASIC. The trouble is, it uses
hi-ASCII (the pi symbol in particular screws up OLX readers) throughout
and it would span about 10 messages raw.
Could I have permission to ZIP it and PostIt! for the users here?
Here's the source header, which explains what it is fairly well, in case
you're wondering what use it would be to the regulars here:
$IF 0
THE * ARDAF15.BAS
AMAZING *
RECURSIVE * *** * *
DESCENT * * * *
ALGEBRAIC ****** * * * *
FORMULA * `****' * *
AND ** ***************************************
DEFINABLE * *
FUNCTIONS * *
ENGINE *****' * * *
* * *
* * * *
* * * * 5(100-x+2b) * * *
* * * * * * *
* * * ************* * * *
* * * * `******
* * * 3!+35y * *
* * * * *
* * * * `****'
v1.5 * * *
Public Domain Code Written
By
Jamshid Khoshrangi
DEDICATION:
This program is dedicated to my wife Laleh, and our three children,
Parvaneh, Shahraam, and Arehzou, who give up a lot of their time
with me so I can program at this infernal keyboard!
WHAT IS IT?
Have you ever wanted to be able to have a user enter in a formula
and solve it on the spot, rather than have to hard code it into
your BASIC program? Suppose your user wants to enter 5*1.5 rather
than a literal 7.5? How to do it? You have to write a parser to
be able to do that! Well, not exactly. I've already written one.
In fact, I wrote RDF14.BAS some time ago for QuickBASIC users and
posted it in FidoNet's QUIK_BAS echo. Now, I'm a confirmed
PowerBASIC user (don't even have QB on my drive anymore). It's
about time we had something like this....
This is NOT like Hanlin's EVAL function, which solved simple stuff
like 5*1.5. ARDAF 1.5 can solve formulas like this:
distance(x1,y1,z1:0,x2,y2,z2:0) :=
/((x1-x2)2+(y1-y2)2+(z1-z2)2)
Just what all that means will become clearer soon....
Let's just say that I didn't call it THE AMAZING RECURSIVE DESCENT
ALGEBRAIC FORMULA AND DEFINABLE FUNCTIONS ENGINE for nothing! ;)
RELEASE NOTES:
Versions 1.0 through 1.4 of ARDAF were known simply as RDF1x.BAS
and were written when my name was Quinn Tyler Jackson. These
versions were QBASIC 1.0 compatible, which means they could be
run under MS-DOS's QBASIC interpreter they were so simple.
With this release, version 1.5, I have ported the original RDF
engine over to PowerBASIC entirely and I have corrected some of
my original cryptic variable names, although some remain crytpic.
With v1.5 I have also made it possible to enter formulas in
using a more natural algebraic notation, rather than the typical
programming language notation, although the algebraic notation
is not strictly necessary.
For instance, previous versions required this syntax:
x := 5*y
whereas from v1.5, this is legal:
x := 5y
Note, however, that there are limitations to this. Since ARDAF
allows variable names to be greater than one character long, this
is not interpreted the same way it would be in pure algebra:
x := 5xy
In algebra, that would mean:
x equals 5 times x times y.
In ARDAF, the "xy" portion would be a single variable. If what
the user really meant was "5 times x times y" then he would have
to supply:
x := 5*x*y
This would also be possible:
x:= 5x*y
Parentheses imply multiplication, just as in algebra. Therefore,
expressions like:
x := 5(y + 1)
are perfectly legal in v1.5.
The new syntax means that more regular algebraic formulas are
possible, such as:
5x+2 -- > 17 for x = 3
(x+3)(3x) -- > 15 for x = 3
10/4 -- > 20
92 -- > 81
(NB: Although 5x means "5 times x", x5 does not mean
"x times 5." In fact, x5 is a complete variable name.)
SYNTAX NOTES:
ARDAF uses a very simple, intuitive syntax that is BODMAS compliant.
That is to say, standard precedence rules apply to ARDAF.
Descriptively named variables are possible with ARDAF, such as:
area_of_square(length_of_side) := length_of_side2
>>> Continued to next message
--- Maximus/2 2.01wb
---------------
* Origin: Sound Stage BBS - Live Via Satellite - (604)944-6476 (1:153/7070)
|