Quantcast
Channel: Dot Operator in Haskell: need more explanation - Stack Overflow
Viewing all articles
Browse latest Browse all 7

Dot Operator in Haskell: need more explanation

$
0
0

I'm trying to understand what the dot operator is doing in this Haskell code:

sumEuler = sum . (map euler) . mkList

The entire source code is below.

My understanding

The dot operator is taking the two functions sum and the result of map euler and the result of mkList as the input.

But, sum isn't a function it is the argument of the function, right? So what is going on here?

Also, what is (map euler) doing?

Code

mkList :: Int -> [Int]mkList n = [1..n-1]euler :: Int -> Inteuler n = length (filter (relprime n) (mkList n))sumEuler :: Int -> IntsumEuler = sum . (map euler) . mkList

Viewing all articles
Browse latest Browse all 7

Latest Images

Trending Articles





Latest Images