I have this function
result =
add 1 2 |> \a -> a % 2 == 0)
and I am getting this error
Elm does not use (%) as the remainder operator
When I look at the docs I see I can use modBy
, so I tried this.
result =
add 1 2 |> (\a -> a modBy 2 == 0)
But that gives me the following error.
This function cannot handle the argument sent through the (|>) pipe:
The %
operator was removed in 0.19
to reduce the confusion between rem
and mod
.
modBy
and remainderBy
are regular functions. You use them like:
result = add 1 2 |> (\a -> modBy 2 a == 0)
or, if you prefer a functional composition variant of the code:
result = add 1 2 |> modBy 2 >> (==) 0
As a historical note, there used to be a way to call functions infix using backticks notation:
a `modBy` 2
but this was removed in 0.18
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With