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 6c06817 commit f581049Copy full SHA for f581049
lib/elixir/lib/enum.ex
@@ -4491,7 +4491,7 @@ defmodule Enum do
4491
4492
{count,
4493
fn start, amount, _step ->
4494
- list |> :lists.reverse() |> slice_exact(start, amount, 1, 1)
+ list |> :lists.reverse() |> slice_exact(start, amount, 1, count)
4495
end}
4496
end
4497
lib/elixir/test/elixir/enum_test.exs
@@ -265,6 +265,20 @@ defmodule EnumTest do
265
266
267
268
+ test "drop/2 with streams" do
269
+ drop_stream = fn list, count -> list |> Stream.map(& &1) |> Enum.drop(count) end
270
+
271
+ assert drop_stream.([1, 2, 3], 0) == [1, 2, 3]
272
+ assert drop_stream.([1, 2, 3], 1) == [2, 3]
273
+ assert drop_stream.([1, 2, 3], 2) == [3]
274
+ assert drop_stream.([1, 2, 3], 3) == []
275
+ assert drop_stream.([1, 2, 3], 4) == []
276
+ assert drop_stream.([1, 2, 3], -1) == [1, 2]
277
+ assert drop_stream.([1, 2, 3], -2) == [1]
278
+ assert drop_stream.([1, 2, 3], -4) == []
279
+ assert drop_stream.([], 3) == []
280
+ end
281
282
test "drop_every/2" do
283
assert Enum.drop_every([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 2) == [2, 4, 6, 8, 10]
284
assert Enum.drop_every([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 3) == [2, 3, 5, 6, 8, 9]
0 commit comments