Reputation: 3
I am trying to do Haskell version of 2^n integer list. numsFrom generate infinite sequence, I want to map this sequence into number 2, but I have an error message:
Possible cause: ‘map’ is applied to too many arguments.
numsFrom :: Int -> [Int]
numsFrom n = n : numsFrom (n+1)
powerOf2 :: Int -> [Int]
powerOf2 = map(^numsFrom 1) 2
Upvotes: 0
Views: 352
Reputation: 747
powerOf2
signature must be powerOf2 :: [Int]
. numsFrom
returns a list to be mapped, so the function to map is (2^)
:
powerOf2 :: [Int]
powerOf2 = map (2^) (numsFrom 1)
PD: Note that you don't need numsFrom
function:
powerOf2 :: [Int]
powerOf2 = map (2^) [1..]
Upvotes: 1