Elm 的余数运算符是什么
What is the remainder operator for Elm
我有这个功能
result =
add 1 2 |> \a -> a % 2 == 0)
我收到了这个错误
Elm does not use (%) as the remainder operator
当我查看文档时,我发现我可以使用 modBy
,所以我尝试了这个。
result =
add 1 2 |> (\a -> a modBy 2 == 0)
但这给了我以下错误。
This function cannot handle the argument sent through the (|>) pipe:
%
运算符已在 0.19
中删除,以减少 rem
和 mod
之间的混淆。
modBy
和 remainderBy
是常规函数。您可以像这样使用它们:
result = add 1 2 |> (\a -> modBy 2 a == 0)
或者,如果您更喜欢代码的功能组合变体:
result = add 1 2 |> modBy 2 >> (==) 0
作为历史记录,曾经有一种使用反引号表示法调用函数中缀的方法:
a `modBy` 2
但这已在 0.18
中删除
我有这个功能
result =
add 1 2 |> \a -> a % 2 == 0)
我收到了这个错误
Elm does not use (%) as the remainder operator
当我查看文档时,我发现我可以使用 modBy
,所以我尝试了这个。
result =
add 1 2 |> (\a -> a modBy 2 == 0)
但这给了我以下错误。
This function cannot handle the argument sent through the (|>) pipe:
%
运算符已在 0.19
中删除,以减少 rem
和 mod
之间的混淆。
modBy
和 remainderBy
是常规函数。您可以像这样使用它们:
result = add 1 2 |> (\a -> modBy 2 a == 0)
或者,如果您更喜欢代码的功能组合变体:
result = add 1 2 |> modBy 2 >> (==) 0
作为历史记录,曾经有一种使用反引号表示法调用函数中缀的方法:
a `modBy` 2
但这已在 0.18