Skip to content

Commit e2eb2cf

Browse files
author
José Valim
committed
Remove broken List.unzip
1 parent a5b4c1c commit e2eb2cf

File tree

4 files changed

+3
-30
lines changed

4 files changed

+3
-30
lines changed

lib/elixir/lib/gen_event.ex

+2-2
Original file line numberDiff line numberDiff line change
@@ -683,8 +683,8 @@ defmodule GenEvent do
683683

684684
@doc false
685685
def system_replace_state(fun, [name, handlers, hib]) do
686-
[handlers, states] =
687-
List.unzip(for handler <- handlers do
686+
{handlers, states} =
687+
:lists.unzip(for handler <- handlers do
688688
handler(module: mod, id: id, state: state) = handler
689689
cur = {mod, id, state}
690690
try do

lib/elixir/lib/kernel.ex

+1-1
Original file line numberDiff line numberDiff line change
@@ -1643,7 +1643,7 @@ defmodule Kernel do
16431643
16441644
iex> users = [%{name: "john", age: 27}, %{name: "meg", age: 23}]
16451645
iex> all = fn :get_and_update, data, next ->
1646-
...> Enum.map(data, next) |> List.unzip() |> List.to_tuple()
1646+
...> Enum.map(data, next) |> :lists.unzip
16471647
...> end
16481648
iex> get_and_update_in(users, [all, :age], &{&1, &1 + 1})
16491649
{[27, 23], [%{name: "john", age: 28}, %{name: "meg", age: 24}]}

lib/elixir/lib/list.ex

-20
Original file line numberDiff line numberDiff line change
@@ -324,26 +324,6 @@ defmodule List do
324324
do_zip(list_of_lists, [])
325325
end
326326

327-
@doc """
328-
Unzips the given list of tuples into a list of lists.
329-
330-
The number of unzipped elements is equal to the size
331-
of the smallest tuple in the list.
332-
333-
## Examples
334-
335-
iex> List.unzip([{1, 2}, {3, 4}])
336-
[[1, 3], [2, 4]]
337-
338-
iex> List.unzip([{1, :a, "apple"}, {2, :b, "banana"}, {3, :c}])
339-
[[1, 2, 3], [:a, :b, :c]]
340-
341-
"""
342-
@spec unzip([tuple]) :: [list]
343-
def unzip(list) when is_list(list) do
344-
:lists.map &Tuple.to_list/1, zip(list)
345-
end
346-
347327
@doc """
348328
Returns a list with `value` inserted at the specified `index`.
349329
Note that `index` is capped at the list length. Negative indices

lib/elixir/test/elixir/list_test.exs

-7
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,6 @@ defmodule ListTest do
7575
assert List.zip([[1, 4], [2, 5], []]) == []
7676
end
7777

78-
test :unzip do
79-
assert List.unzip([{1, 2, 3}, {4, 5, 6}]) == [[1, 4], [2, 5], [3, 6]]
80-
assert List.unzip([{1, 2, 3}, {4, 5}]) == [[1, 4], [2, 5]]
81-
assert List.unzip([[1, 2, 3], [4, 5]]) == [[1, 4], [2, 5]]
82-
assert List.unzip([]) == []
83-
end
84-
8578
test :keyfind do
8679
assert List.keyfind([a: 1, b: 2], :a, 0) == {:a, 1}
8780
assert List.keyfind([a: 1, b: 2], 2, 1) == {:b, 2}

0 commit comments

Comments
 (0)