swarm-support
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Handling equations as objects


From: Benedikt Stefansson
Subject: Re: Handling equations as objects
Date: Wed, 19 Aug 1998 16:56:50 -0600

This is an interesting problem,

I haven't found a solution for it myself, but the first idea that pops
into my head is that one of the texbooks that I used when I was learning
C contained code for a C interpreter written in C:

        C : The Complete Reference 
        Herbert Schildt
        Paperback - 912 pages 3rd edition (March 1995) 
        Osborne McGraw-Hill; ISBN: 0078821010 

By the way the book itself is clearly and well written but according to
most good C programmers both misleading and dangerous, professional
programmes have apparently immortalized poor Herbert by coining the term
"bullschildt" for a horribly wrong assertion (about a programming
language) which is nonchalantly presented as fact. In other words, don't
spend your hard earned money on this book, but borrow it from the
library. 

Anyway, I think the C interpreter works. One could wrap an object around
this code (or perhaps some even simpler expression parser if one can be
found), and put in features to read the equations from strings or from
files. Basically it would behave like an ObjectLoader or InFile object: 

        +readExpressionFromString: (char *) s;
        +readExpressionFromFile: (FILE *) f;

The tricky part is to pass in the values for the equation arguments, the
cleanest way would probably be a another wrapper, (? <FunctionValues>)
subclassed from List maybe, which could contain an arbitrary long array
of values, where the order and number of arguments would probably have
to be known at compile time. Then the Expression object could have a
method such as:

        +(double) evaluateExpressionWith: (id <FunctionValues>) v;

I hope that this idea prompts someone to cry 'overkill' and come up with
a neater solution...and I think a solution could be very useful indeed.

-Benedikt
------------------------------------------------------------------
Department of Economics, UCLA, Los Angeles, CA 90095-1477, USA
Tel: (310) 825 4126     Fax: (310) 825 9528   <address@hidden>

8/2-8/31 1998:
Santa Fe Institute, 1399 Hyde Park Road, New Mexico 87501 USA
Tel: (505) 984 8800     Fax: (505) 982 0565   <address@hidden>
------------------------------------------------------------------

                  ==================================
   Swarm-Support is for discussion of the technical details of the day
   to day usage of Swarm.  For list administration needs (esp.
   [un]subscribing), please send a message to <address@hidden>
   with "help" in the body of the message.
                  ==================================


reply via email to

[Prev in Thread] Current Thread [Next in Thread]