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

List:       ruby-talk
Subject:    Re: Exact (LISP-ish) calculations in Ruby?
From:       David Masover <ninja () slaphack ! com>
Date:       2009-11-18 17:23:32
Message-ID: 200911181123.20089.ninja () slaphack ! com
[Download RAW message or body]

On Wednesday 18 November 2009 08:35:36 am Aldric Giacomoni wrote:
> Has anyone written a gem for exact calculations? The kind one would find
> on a LISP REPL, or when using your average HP scientific calculator?
> 
> >> 3 / 4
> 
> => 3/4

This much is available through the Rational object:

irb(main):001:0> Rational 3,4
=> (3/4)
irb(main):002:0> Rational(3) / 4
=> (3/4)
irb(main):003:0> Rational(3) / 4 / 12
=> (1/16)

I'm not sure about the rest of it, though it makes me wish I'd used Lisp for a 
recent project. I pretty much had to invent a symbolic equation manipulation 
class -- though, to be fair, I didn't look that hard for an existing one.

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

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