[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ruby-talk
Subject:    Re: Exact (LISP-ish) calculations in Ruby?
From:       Aldric Giacomoni <aldric () trevoke ! net>
Date:       2009-11-20 13:05:10
Message-ID: f12c958b7994ca57a546c6a1c78d1976 () ruby-forum ! com
[Download RAW message or body]

David Masover wrote:
> Macros would let me actually do something like this:
> 
> (differentiate (- (expt x 3) 7))
> 
> If we could do the equivalent in Ruby, it'd look like this:
> 
> Math.differentiate {|x| x**3 - 7}
> 
> That's kind of gross to implement, though. Pure does it by discarding 
> the
> block, finding the original source, and re-parsing it, using whatever 
> parse
> tool is available, to get the actual parse tree.
> 
> I decided to start with the object model, and try to add a DSL later.
> The following actually works:
> 
> irb(main):004:0> (E(:x)**3 - 7).integrate :x
> => ((x^4/4)+((-7)*x))
> [...]
> But really, I've done this as a learning exercise. As a tool, I'd still
> probably use Maxima.

Everyone's talking about Maxima, which was written in LISP.. Interesting 
:)
I'd like to modify the earlier question then, and wonder if Ruby is the 
right tool for the job, or if one should simply just go with LISP (in 
which case, there's no reinventing the wheel, I'd just use Maxima). If 
Ruby can be the right tool for the job.. Is it worth it? :)

I do think it would be pretty cool to have a CAS like Maxima in Ruby 
(there is in fact a rubyforge project to develop one, but it hasn't 
released any files at all yet).
-- 
Posted via http://www.ruby-forum.com/.

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic