We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ff73830 commit a1a37c6Copy full SHA for a1a37c6
lib/elixir/lib/range.ex
@@ -387,16 +387,11 @@ defimpl Enumerable, for: Range do
387
{:done, acc}
388
end
389
390
- def member?(first..last//step = range, value) when is_integer(value) do
391
- cond do
392
- Range.size(range) == 0 ->
393
- {:ok, false}
394
-
395
- first <= last ->
396
- {:ok, first <= value and value <= last and rem(value - first, step) == 0}
397
398
- true ->
399
- {:ok, last <= value and value <= first and rem(value - first, step) == 0}
+ def member?(first..last//step, value) when is_integer(value) do
+ if step > 0 do
+ {:ok, first <= value and value <= last and rem(value - first, step) == 0}
+ else
+ {:ok, last <= value and value <= first and rem(value - first, step) == 0}
400
401
402
0 commit comments