I want to make a list of numbers every 0.1from -150to 150.
To do this, I created a list and then tried to display lambda fractional multiplication on it, for example:
let indices = [-1500,-1499..1500]
let grid = map (\x -> 0.1 *x) indices
This causes ghci to spit out an error.
On the other hand, both of these functions work fine:
let a = 0.1*2
and
let grid = map (\x -> 2 *x) indices
What's going on here? Why does multiplication of a number by a fractional number occur only when applied to a list with a map?
EDIT: The error I get is:
No instance for (Fractional Integer)
arising from the literal `0.1'
Possible fix: add an instance declaration for (Fractional Integer)
In the first argument of `(*)', namely `0.1'
In the expression: 0.1 * x
In the first argument of `map', namely `(\ x -> 0.1 * x)'
source
share