Automatic Equation and Inequation evaluation.

Carlos checoimg at gmail.com
Sat Jun 15 04:44:02 PDT 2013


On Saturday, 15 June 2013 at 08:46:13 UTC, John Colvin wrote:
> On Saturday, 15 June 2013 at 02:05:00 UTC, Carlos wrote:
>> I'm interested in this kind of functionalities; Does D have
>> something on this ?
>>
>> I thought about something like a "eval" function that would use
>> specified algorithms.
>> something likes this
>>
>> import std.stdio, std.math, std.eval;
>>
>> void main()
>> {
>> eval(Real; a+b^^x+c=56){
>> algor.brute(&result);
>>       }
>> writeln("Positive value is : ", result);
>> }
>
> It's not clear what that would do from your example. I presume 
> a, b and c are defined somewhere and eval solves for x?

algor.brute does the work. IF you know that algorithm you would 
know what it does.
Another question would be if this way of coding makes sense to 
you.

This is what the "eval" function does ( in theory ), It takes The 
words : Real, Rational, Irrational or R, Q , Q' and from there is 
defined which numerical group is going to be used for the 
evaluation. Then it identifies the operators and variables and 
defines the equation in a format like a text format with a end 
file character in the end so equations can be as long as you 
want. After that between {algor.(name)} in name you call the 
algorithm you want to use for the evaluation there can be 
predefined algorithm with D but maybe you can define your own 
algorithms.

What do you think does this makes sense or would you implement it 
other way ?


More information about the Digitalmars-d mailing list