Haskell Even Function?
haskell
Solution
The code works fine if you change `even n` to `even ns`:
squareEvens n = [ns * ns | ns <- n, even ns]
But note that the convention is to use the plural to name the list and the singular to name an element from that list. So swap `n` and `ns` to follow idiomatic Haskell usage:
squareEvens ns = [n * n | n <- ns, even n]
Problem
This is probably a fairly obvious question, but I just can't figure it out. I am trying to write a function that squares the even numbers in a list. When I try to run it, I am getting an error about my use of the even function. How can I fix this? ``` module SquareEvens where squareEvens :: [Integer] -> [Integer] squareEvens n = [ns * ns | ns <- n, even n] ```