[Haskell-cafe] newbie q about types
lrpalmer at gmail.com
Sat Feb 2 01:41:03 EST 2008
Look at the type of tail:
tail :: [a] -> [a]
That is, tail is the list of all elements *except* the head. You want "last".
(Barring style considerations. Usually in a situation like this you
would use a list of tuples rather than a list of lists, since then you
know at compile time that you have exactly two numbers in each element
of the list).
On Feb 2, 2008 6:30 AM, Logesh Pillay <lpillay at webafrica.org.za> wrote:
> I have a list. Each component is a list with 2 whole numbers. I want
> to multiply the second number by the log of the first
> tail ([519432,525806]) * log (head [519432,525806]).
> I get the ffg error message:
> No instance for (Floating [t])
> arising from a use of `log' at <interactive>:1:25-50
> Possible fix: add an instance declaration for (Floating [t])
> In the second argument of `(*)', namely
> `log (head [519432, 525806])'
> In the expression:
> tail ([519432, 525806]) * log (head [519432, 525806])
> In the definition of `it':
> it = tail ([519432, 525806]) * log (head [519432, 525806])
> I've tried the only type signature I know "fromIntegral" but it does not
> How to fix?
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
More information about the Haskell-Cafe