Skip to content

Commit f3f64cd

Browse files
author
José Valim
committed
Move to capture syntax
1 parent 5b8a30b commit f3f64cd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+291
-361
lines changed

lib/eex/lib/eex/compiler.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ defmodule EEx.Compiler do
6868
else
6969
key = length(state.dict)
7070
placeholder = '__EEX__(' ++ integer_to_list(key) ++ ');'
71-
{ current ++ placeholder ++ new_lines ++ chars, state.update_dict([{key, buffer}|&1]) }
71+
{ current ++ placeholder ++ new_lines ++ chars, state.update_dict(&[{key, buffer}|&1]) }
7272
end
7373
end
7474

@@ -108,7 +108,7 @@ defmodule EEx.Compiler do
108108
end
109109

110110
defp insert_quotes(list, dict) when is_list(list) do
111-
Enum.map list, insert_quotes(&1, dict)
111+
Enum.map list, &insert_quotes(&1, dict)
112112
end
113113

114114
defp insert_quotes(other, _dict) do

lib/eex/lib/eex/tokenizer.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ defmodule EEx.Tokenizer do
136136
end
137137

138138
defp end_index(tokens) do
139-
Enum.find_index(tokens, match?({ :end, _ }, &1)) || :infinity
139+
Enum.find_index(tokens, &match?({ :end, _ }, &1)) || :infinity
140140
end
141141

142142
defp check_spaces(string, token) do

lib/elixir/lib/code.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ defmodule Code do
166166
end
167167

168168
defp validate_requires(kind, requires) do
169-
valid = is_list(requires) and Enum.all?(requires, is_atom(&1))
169+
valid = is_list(requires) and Enum.all?(requires, &is_atom(&1))
170170

171171
unless valid do
172172
raise ArgumentError, "expected :#{kind} option given to eval in the format: [module]"

lib/elixir/lib/enum.ex

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ defmodule Enum do
473473
474474
## Examples
475475
476-
iex> Enum.filter_map([1, 2, 3], fn(x) -> rem(x, 2) == 0 end, &1 * 2)
476+
iex> Enum.filter_map([1, 2, 3], fn(x) -> rem(x, 2) == 0 end, &(&1 * 2))
477477
[4]
478478
479479
"""
@@ -892,8 +892,8 @@ defmodule Enum do
892892
end
893893

894894
def sort(collection) do
895-
fun = &1 <= &2
896-
Enumerable.reduce(collection, [], sort_reducer(&1, &2, fun)) |>
895+
fun = &(&1 <= &2)
896+
Enumerable.reduce(collection, [], &sort_reducer(&1, &2, fun)) |>
897897
sort_terminator(fun)
898898
end
899899

@@ -912,7 +912,7 @@ defmodule Enum do
912912
end
913913

914914
def sort(collection, fun) do
915-
Enumerable.reduce(collection, [], sort_reducer(&1, &2, fun)) |>
915+
Enumerable.reduce(collection, [], &sort_reducer(&1, &2, fun)) |>
916916
sort_terminator(fun)
917917
end
918918

lib/elixir/lib/file.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -938,7 +938,7 @@ defmodule File do
938938
"""
939939
def ls(path // ".") do
940940
case F.list_dir(path) do
941-
{ :ok, file_list } -> { :ok, Enum.map(file_list, to_string(&1)) }
941+
{ :ok, file_list } -> { :ok, Enum.map(file_list, &to_string(&1)) }
942942
{ :error, _ } = error -> error
943943
end
944944
end

lib/elixir/lib/gen_fsm/behaviour.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ defmodule GenFSM.Behaviour do
6060
end
6161
6262
def short_paid(:coin, state_data) do
63-
{ :next_state, :paid_in_full, state_data.update_coins(&1 + 1) }
63+
{ :next_state, :paid_in_full, &state_data.update_coins(&1 + 1) }
6464
end
6565
6666
def short_paid(:request_coffee, state_data) do
@@ -84,7 +84,7 @@ defmodule GenFSM.Behaviour do
8484
8585
8686
def paid_in_full(:coin, state_data) do
87-
{ :next_state, :paid_in_full, state_data.update_coins(&1 + 1) }
87+
{ :next_state, :paid_in_full, &state_data.update_coins(&1 + 1) }
8888
end
8989
9090
def paid_in_full(:request_coffee, _state_data) do

lib/elixir/lib/hash_dict.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,13 +153,13 @@ defmodule HashDict do
153153

154154
def merge(dict1, dict2, callback) when is_record(dict1, HashDict) and is_record(dict2, HashDict) and elem(dict1, 1) < elem(dict2, 1) do
155155
dict_fold dict1, dict2, fn [k|v1], acc ->
156-
update(acc, k, v1, callback.(k, v1, &1))
156+
update(acc, k, v1, &callback.(k, v1, &1))
157157
end
158158
end
159159

160160
def merge(dict1, dict2, callback) when is_record(dict1, HashDict) and is_record(dict2, HashDict) do
161161
dict_fold dict2, dict1, fn [k|v2], acc ->
162-
update(acc, k, v2, callback.(k, &1, v2))
162+
update(acc, k, v2, &callback.(k, &1, v2))
163163
end
164164
end
165165

lib/elixir/lib/hash_set.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ defmodule HashSet do
103103
end
104104

105105
def to_list(set) do
106-
set_fold(set, [], [&1|&2]) |> :lists.reverse
106+
set_fold(set, [], &[&1|&2]) |> :lists.reverse
107107
end
108108

109109
def put(set, member) do

lib/elixir/lib/inspect.ex

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,9 @@ defimpl Inspect, for: List do
267267
:io_lib.printable_list(thing) ->
268268
<< ?', Inspect.BitString.escape(String.from_char_list!(thing), ?') :: binary, ?' >>
269269
keyword?(thing) && not opts.raw ->
270-
surround_many("[", thing, "]", opts.limit, keyword(&1, opts))
270+
surround_many("[", thing, "]", opts.limit, &keyword(&1, opts))
271271
true ->
272-
surround_many("[", thing, "]", opts.limit, Kernel.inspect(&1, opts))
272+
surround_many("[", thing, "]", opts.limit, &Kernel.inspect(&1, opts))
273273
end
274274
end
275275

@@ -317,7 +317,7 @@ defimpl Inspect, for: Tuple do
317317
def inspect(tuple, opts) do
318318
unless opts.raw do
319319
record_inspect(tuple, opts)
320-
end || surround_many("{", tuple_to_list(tuple), "}", opts.limit, Kernel.inspect(&1, opts))
320+
end || surround_many("{", tuple_to_list(tuple), "}", opts.limit, &Kernel.inspect(&1, opts))
321321
end
322322

323323
## Helpers
@@ -331,7 +331,7 @@ defimpl Inspect, for: Tuple do
331331
else
332332
surround_record(name, fields, tail, opts)
333333
end
334-
end || surround_many("{", [name|tail], "}", opts.limit, Kernel.inspect(&1, opts))
334+
end || surround_many("{", [name|tail], "}", opts.limit, &Kernel.inspect(&1, opts))
335335
end
336336

337337
defp record_fields(name) do
@@ -351,7 +351,7 @@ defimpl Inspect, for: Tuple do
351351

352352
concat(
353353
Inspect.Atom.inspect(name, opts),
354-
surround_many("[", Enum.zip(fields, tail), "]", opts.limit, keyword(&1, opts))
354+
surround_many("[", Enum.zip(fields, tail), "]", opts.limit, &keyword(&1, opts))
355355
)
356356
end
357357

lib/elixir/lib/inspect/algebra.ex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ defmodule Inspect.Algebra do
113113
Concatenates a list of documents.
114114
"""
115115
@spec concat([t]) :: doc_cons_t
116-
def concat(docs), do: folddoc(docs, concat(&1, &2))
116+
def concat(docs), do: folddoc(docs, &concat(&1, &2))
117117

118118
@doc """
119119
Nests document entity `x` positions deep. Nesting will be
@@ -273,11 +273,11 @@ defmodule Inspect.Algebra do
273273
274274
## Examples
275275
276-
iex> doc = Inspect.Algebra.surround_many("[", Enum.to_list(1..5), "]", :infinity, integer_to_binary(&1))
276+
iex> doc = Inspect.Algebra.surround_many("[", Enum.to_list(1..5), "]", :infinity, &integer_to_binary(&1))
277277
iex> Inspect.Algebra.pretty(doc, 5)
278278
"[1,\n 2,\n 3,\n 4,\n 5]"
279279
280-
iex> doc = Inspect.Algebra.surround_many("[", Enum.to_list(1..5), "]", 3, integer_to_binary(&1))
280+
iex> doc = Inspect.Algebra.surround_many("[", Enum.to_list(1..5), "]", 3, &integer_to_binary(&1))
281281
iex> Inspect.Algebra.pretty(doc, 20)
282282
"[1, 2, 3, ...]"
283283

0 commit comments

Comments
 (0)