How do I make the power function, doubles and [..] working together in frege? -
while
map (\x -> x * x) [0..9]
is working fine (also list comprehension), cannot do
map (** 2) [0..9]
since power operator requires doubles , .. operator not allow them.
is there mapping can use?
the reason double not instance of enum.
there 2 possibilities:
- make double instance of enum.
- use function converts int values numeric type need:
for example:
(map (** 2) . map fromint) [0..9]
or, if prefer:
map ((** 2) . fromint) [0..9]
Comments
Post a Comment