[Haskell-cafe] type Rational and the % operator
michael rice
nowgate at yahoo.com
Sat Mar 28 22:36:22 EDT 2009
That fixed the problem with recognizing the % operator, but what's it trying to tell me now?
Michael
============
import Data.Ratio
cf :: [Integer] -> Rational
cf (x:xs) = (toRational x) + (1 % (cf xs))
cf (x:[]) = toRational x
cf [] = toRational 0
Data.Ratio> :load cf.hs
ERROR "cf.hs":3 - Type error in application
*** Expression : toRational x + 1 % cf xs
*** Term : toRational x
*** Type : Ratio Integer
*** Does not match : Ratio (Ratio Integer)
--- On Sat, 3/28/09, Duane Johnson <duane.johnson at gmail.com> wrote:
From: Duane Johnson <duane.johnson at gmail.com>
Subject: Re: [Haskell-cafe] type Rational and the % operator
To: "michael rice" <nowgate at yahoo.com>
Cc: haskell-cafe at haskell.org
Date: Saturday, March 28, 2009, 9:44 PM
I believe it's
import Data.Ratio
I found it on hayoo... http://holumbus.fh-wedel.de/hayoo/hayoo.html?query=%25#0:%25
-- Duane Johnson
On Mar 28, 2009, at 7:39 PM, michael rice wrote:
Hi,
I've been away from Haskell Land for a while, but I think the function cf below, given a list of Ints should calculate a continuous fraction. I'm using Hugs 98 and get errors when loading and also when trying to use the % operator at the command prompt (see below). What must I do to get this to work?
Michael
===============
cf :: [Int] -> Rational
cf [] = 0
cf (x:[]) = 1 % x
cf (x:xs) = x + (1 % cf xs)
Hugs> :load cf.hs
ERROR "cf.hs":2 - Undefined variable "%"
Hugs>
Hugs> 1 % 5
ERROR - Undefined variable "%"
Hugs>
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe at haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090328/c520e30a/attachment.htm
More information about the Haskell-Cafe
mailing list