Why is strong emphasis used when passing a mod function to display?

I am studying Haskell, but I did not find the answer to this question.

Why is serious emphasis used to pass the mod function to display, as in the example? I have seen other cases with other functions where this is not needed.

 map (`mod` 3) [1..6] -- result is [1,2,0,1,2,0] 

If I pass without a serious accent, the result will be completely different.

 map (mod 3) [1..6] -- result is [0,1,0,3,3,3] 
+6
source share
2 answers

The emphasis "makes the function behave like an operator." For instance:

 mod ab == a `mod` b 

So

 (mod 3) == mod 3 ? 

and

 (`mod` 3) == mod ? 3 
+11
source

If you want to clearly understand what you are thinking about (I always do mine, since I'm still in the learning phase), you can always use an anonymous function (sometimes I call a lambda expression, but I'm not sure)

 > map (\x -> x `mod` 3) [1..10] [1,2,0,1,2,0,1,2,0,1] > map (\x -> 3 `mod` x) [1..10] [0,1,0,3,3,3,3,3,3,3] > map (\x -> mod x 3) [1..10] [1,2,0,1,2,0,1,2,0,1] > map (\x -> mod 3 x) [1..10] [0,1,0,3,3,3,3,3,3,3] 
+1
source

All Articles