1

In this Haskell code:

power a r = [a*(truncate (r**i)) | i <- e]
    where e = [0,10]

I am getting an error with the ** operation because I believe it makes a float. Is there a way to convert it to an int?

1 Answer 1

4

I don't know what you mean by getting an error since your code type-checks, but you probably want the ^ operator:

(^) :: (Integral b, Num a) => a -> b -> a

Your code type-checks just fine with that, too:

power a r = [a*(r^i) | i <- e]
    where e = [0,10]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.