Re: [Haskell-cafe] Arbitrary precision?

2007-05-07 Thread Henning Thielemann

On Sun, 6 May 2007, Andrew Coppin wrote:

 Greetings.

 Haskell has arbitrary precision integers, in the form of the Integer
 type. Is there a type somewhere that implements arbitrary precision
 fractional values?

Whatever you want:
 
http://haskell.org/haskellwiki/Applications_and_libraries/Mathematics#Number_representations

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Arbitrary precision?

2007-05-06 Thread Stefan O'Rear
On Sun, May 06, 2007 at 05:15:08PM +0100, Andrew Coppin wrote:
 Greetings.
 
 Haskell has arbitrary precision integers, in the form of the Integer 
 type. Is there a type somewhere that implements arbitrary precision 
 fractional values?

Yes, Rational in the Prelude (with extra functions in Ratio)

Prelude let fibs = (1::Rational) : 1 : zipWith (+) fibs (tail fibs)
Prelude let grs = zipWith (/) (tail fibs) fibs
Prelude take 10 grs
[1%1,2%1,3%2,5%3,8%5,13%8,21%13,34%21,55%34,89%55]
Prelude take 10 (zipWith (-) grs (tail grs))
[(-1)%1,1%2,(-1)%6,1%15,(-1)%40,1%104,(-1)%273,1%714,(-1)%1870,1%4895]
Prelude
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Arbitrary precision?

2007-05-06 Thread Andrew Coppin



Greetings.

Haskell has arbitrary precision integers, in the form of the Integer 
type. Is there a type somewhere that implements arbitrary precision 
fractional values?



Yes, Rational in the Prelude (with extra functions in Ratio)

Prelude let fibs = (1::Rational) : 1 : zipWith (+) fibs (tail fibs)
Prelude let grs = zipWith (/) (tail fibs) fibs
Prelude take 10 grs
[1%1,2%1,3%2,5%3,8%5,13%8,21%13,34%21,55%34,89%55]
Prelude take 10 (zipWith (-) grs (tail grs))
[(-1)%1,1%2,(-1)%6,1%15,(-1)%40,1%104,(-1)%273,1%714,(-1)%1870,1%4895]
Prelude
  


Ah yes, you're right. Well, you learn something every day...

OOC, is there a reason why you can't just write 5%10?

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Arbitrary precision?

2007-05-06 Thread Brandon S. Allbery KF8NH


On May 6, 2007, at 12:59 , Andrew Coppin wrote:

OOC, is there a reason why you can't just write 5%10?


Prelude :t 5%10

interactive:1:1: Not in scope: `%'
Prelude :m +Data.Ratio
Prelude Data.Ratio :t 5%10
5%10 :: (Integral t) = Ratio t
Prelude Data.Ratio

I'm actually a bit surprised that's not in Prelude.

--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] [EMAIL PROTECTED]
system administrator [openafs,heimdal,too many hats] [EMAIL PROTECTED]
electrical and computer engineering, carnegie mellon universityKF8NH


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Arbitrary precision?

2007-05-06 Thread Andrew Coppin

Brandon S. Allbery KF8NH wrote:

OOC, is there a reason why you can't just write 5%10?


Prelude :t 5%10

interactive:1:1: Not in scope: `%'
Prelude :m +Data.Ratio
Prelude Data.Ratio :t 5%10
5%10 :: (Integral t) = Ratio t
Prelude Data.Ratio

I'm actually a bit surprised that's not in Prelude.


Likewise...

Oh, by the way, thanks for the extra syntax. It's really annoying having 
to locate Notepad.exe on the start menu, type import Blah, save it as 
Thing.hs, open Windoze Explorer, locate Thing.hs, and then 
double-click it just so that I can try stuff out in GHCi...


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Arbitrary precision?

2007-05-06 Thread Jim Burton



Andrew Coppin wrote:
 
 ...
 
 Likewise...
 
 Oh, by the way, thanks for the extra syntax. It's really annoying having 
 to locate Notepad.exe on the start menu, type import Blah, save it as 
 Thing.hs, open Windoze Explorer, locate Thing.hs, and then 
 double-click it just so that I can try stuff out in GHCi...
 
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe
 
 

God that sounds painful. As well as reading about ghci [1] you might
consider Emacs and haskell-mode for a productive environment.  

[1] http://www.haskell.org/ghc/docs/6.4.2/html/users_guide/ghci.html

-- 
View this message in context: 
http://www.nabble.com/Arbitrary-precision--tf3700066.html#a10348633
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Arbitrary precision?

2007-05-06 Thread David House

On 06/05/07, Andrew Coppin [EMAIL PROTECTED] wrote:

Oh, by the way, thanks for the extra syntax. It's really annoying having
to locate Notepad.exe on the start menu, type import Blah, save it as
Thing.hs, open Windoze Explorer, locate Thing.hs, and then
double-click it just so that I can try stuff out in GHCi...


Any reason you can't use :module Blah in GHCi?

--
-David House, [EMAIL PROTECTED]
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe