eki / mathcraft

A mathtastic computer algebra system.
0 stars 0 forks source link

Change substitute to eval? #6

Open eki opened 4 years ago

eki commented 4 years ago

Change substitute to eval (or, evaluate)?

At the same time, change the method to take keyword options or a hash. We'd like to do something like this:

craft!('2x + y + 4').eval(x: 4, y: 3)  # => 15
craft!('2x + y + 4').eval(y: 3)          # => 2x + 7

Evaluation should be lazy or immediate depending on whether we're working with a lazy or immediate object.

It might be nice to have something to convert to a lambda?

eq = craft!('2x + y + 4').to_proc
eq.call(x: 2)  # => y + 8

Although, it's kind of difficult to imagine the value of converting an equation into a lambda?