im currently looking into haskell. I know that i have to make datatypes an instance of Eq in order to compare them. But Int should already be comparable right ? So i dnt know how to handle the following Error:
• No instance for (Eq (Int -> Int)) arising from a use of ‘==’ (maybe you haven't applied a function to enough arguments?)
My Code is as follows:
myRandomList = [1,2,3,4,5,6,7,8,9,10]
myFilterList :: [Int] -> [Int]
myFilterList [] = []
myFilterList (x:xs)
| mod x == 0 = x : myFilterList xs
| otherwise = myFilterList xs
myDotFunc = map (+ 1) . myFilterList . myRandomList
Ps: Im not even sure, if my code would work without this error, please remember that i just started haskell :)
mod x
is not a number, you need to provide an extra argument. – Willem Van OnsemmyRandomList
is not a function,myDotFunc
should probably bemyDotFunc = map (+1) . myFilterList
instead. – Regis Kuckaertz