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

Answer by Russia Must Remove Putin for Dot Operator in Haskell: need more...

Dot Operator in HaskellI'm trying to understand what the dot operator is doing in this Haskell code:sumEuler = sum . (map euler) . mkListShort answerEquivalent code without dots, that is justsumEuler =...

View Article


Answer by Chris Conway for Dot Operator in Haskell: need more explanation

sum is a function in the Haskell Prelude, not an argument to sumEuler. It has the typeNum a => [a] -> aThe function composition operator . has type(b -> c) -> (a -> b) -> a -> cSo...

View Article


Answer by Jesse Rusak for Dot Operator in Haskell: need more explanation

The . operator composes functions. For example,a . bWhere a and b are functions is a new function that runs b on its arguments, then a on those results. Your codesumEuler = sum . (map euler) . mkListis...

View Article

Answer by Andy Mikula for Dot Operator in Haskell: need more explanation

The dot operator applies the function on the left (sum) to the output of the function on the right. In your case, you're chaining several functions together - you're passing the result of mkList to...

View Article

Answer by John Leidegren for Dot Operator in Haskell: need more explanation

The . operator is used for function composition. Just like math, if you have to functions f(x) and g(x) f . g becomes f(g(x)).map is a built-in function which applies a function to a list. By putting...

View Article


Answer by jrockway for Dot Operator in Haskell: need more explanation

Put simply, . is function composition, just like in math:f (g x) = (f . g) xIn your case, you are creating a new function, sumEuler that could also be defined like this:sumEuler x = sum (map euler...

View Article

Dot Operator in Haskell: need more explanation

I'm trying to understand what the dot operator is doing in this Haskell code:sumEuler = sum . (map euler) . mkListThe entire source code is below. My understandingThe dot operator is taking the two...

View Article
Browsing all 7 articles
Browse latest View live


Latest Images