Skip to content

Commit 5465f3c

Browse files
eksperimentaljosevalim
authored andcommitted
Formatting: add white space after comma (elixir-lang#720)
Standardizes the use of comma leaving a white space after it whenever applicable.
1 parent 7478c8f commit 5465f3c

13 files changed

+35
-35
lines changed

Diff for: _posts/2013-05-23-elixir-v0-9-0-released.markdown

+3-3
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ A special thanks to [Eric Meadows-Jonsson](https://github.com/ericmj) for implem
5555
Elixir v0.9.0 changes its main abstraction for enumeration from iterators to reducers. Before Elixir v0.9.0, when you invoked:
5656

5757
```elixir
58-
Enum.map([1,2,3], fn(x) -> x * x end)
58+
Enum.map([1, 2, 3], fn(x) -> x * x end)
5959
#=> [1, 4, 9]
6060
```
6161

62-
It asked the `Enum.Iterator` protocol for instructions on how to iterate the list `[1,2,3]`. This iteration happened by retrieving each item in the list, one by one, until there were no items left.
62+
It asked the `Enum.Iterator` protocol for instructions on how to iterate the list `[1, 2, 3]`. This iteration happened by retrieving each item in the list, one by one, until there were no items left.
6363

6464
This approach posed many problems:
6565

@@ -91,7 +91,7 @@ The implementation above works as a simple `reduce` function (also called `fold`
9191

9292
```elixir
9393
# Sum all elements in a list
94-
Enumerable.reduce([1,2,3], 0, fn(x, acc) -> x + acc end)
94+
Enumerable.reduce([1, 2, 3], 0, fn(x, acc) -> x + acc end)
9595
#=> 6
9696
```
9797

Diff for: _posts/2013-07-13-elixir-v0-10-0-released.markdown

+5-5
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,25 @@ Elixir v0.10.0 is released with support for streams, sets and many improvements
1313
The default mechanism for working with collections in Elixir is the `Enum` module. With it, you can map over ranges, lists, sets, dictionaries and any other structure as long as it implements the `Enumerable` protocol:
1414

1515
```elixir
16-
Enum.map([1,2,3], fn(x) -> x * 2 end)
17-
#=> [2,4,6]
16+
Enum.map([1, 2, 3], fn(x) -> x * 2 end)
17+
#=> [2, 4, 6]
1818
```
1919

2020
The `Enum` module performs eager evaluation. Consider the following example:
2121

2222
```elixir
23-
[1,2,3]
23+
[1, 2, 3]
2424
|> Enum.take_while(fn(x) -> x < 3 end)
2525
|> Enum.map(fn(x) -> x * 2 end)
26-
#=> [2,4]
26+
#=> [2, 4]
2727
```
2828

2929
In the example above, we enumerate the items in list once, taking all elements that are less than 3, and then we enumerate the remaining elements again, multiplying them by two. In order to retrieve the final result, we have created one intermediate list. As we add more operations, more intermediate lists will be generated.
3030

3131
This approach is simple and efficient for the majority of the cases but, when working with large collections, we can generate many, possibly large, intermediate lists affecting performance. That's one of the problems Streams solve. Let's rewrite the example above using Streams:
3232

3333
```elixir
34-
[1,2,3]
34+
[1, 2, 3]
3535
|> Stream.take_while(fn(x) -> x < 3 end)
3636
|> Stream.map(fn(x) -> x * 2 end)
3737
#=> #Stream.Lazy<...>

Diff for: _posts/2013-08-08-elixir-design-goals.markdown

+7-7
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ Many language constructs are also inspired by their Erlang counter-parts, like s
145145
tuple = { 1, 2, 3 }
146146

147147
# Adding two lists
148-
[1,2,3] ++ [4,5,6]
148+
[1, 2, 3] ++ [4, 5, 6]
149149

150150
# Case
151151
case expr do
@@ -161,7 +161,7 @@ maps to Erlang:
161161
Tuple = { 1, 2, 3 }.
162162

163163
% Adding two lists
164-
[1,2,3] ++ [4,5,6].
164+
[1, 2, 3] ++ [4, 5, 6].
165165

166166
% Case
167167
case Expr of
@@ -189,17 +189,17 @@ And much more.
189189
Most of the features above provide their own extensibility mechanisms, too. For example, take the `Enum` module. The `Enum` module allow us to enumerate the built-in ranges, lists, sets, etc:
190190

191191
```elixir
192-
list = [1,2,3]
192+
list = [1, 2, 3]
193193
Enum.map list, fn(x) -> x * 2 end
194-
#=> [2,4,6]
194+
#=> [2, 4, 6]
195195

196196
range = 1..3
197197
Enum.map range, fn(x) -> x * 2 end
198-
#=> [2,4,6]
198+
#=> [2, 4, 6]
199199

200-
set = HashSet.new [1,2,3]
200+
set = HashSet.new [1, 2, 3]
201201
Enum.map set, fn(x) -> x * 2 end
202-
#=> [2,4,6]
202+
#=> [2, 4, 6]
203203
```
204204

205205
Not only that, any developer can **extend** the `Enum` module to work with any data type as long as the data type implements [the `Enumerable` protocol](/docs/stable/elixir/Enumerable.html) (protocols in Elixir are based on Clojure's protocol). This is extremely convenient because the developer needs to know only the `Enum` API for enumeration, instead of memorizing specific APIs for sets, lists, dicts, etc.

Diff for: _posts/2013-12-11-elixir-s-new-continuable-enumerators.markdown

+1-1
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ defmodule Interleave do
186186
end
187187
end
188188

189-
Interleave.interleave([1,2], [:a, :b, :c, :d])
189+
Interleave.interleave([1, 2], [:a, :b, :c, :d])
190190
#=> [1, :a, 2, :b, :c, :d]
191191
```
192192

Diff for: _posts/2014-04-21-elixir-v0-13-0-released.markdown

+1-1
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ As in previous Elixir versions, there is also support for a bitstring generator.
212212
```iex
213213
iex> pixels = <<213, 45, 132, 64, 76, 32, 76, 0, 0, 234, 32, 15>>
214214
iex> for <<r::8, g::8, b::8 <- pixels>>, do: {r, g, b}
215-
[{213,45,132}, {64,76,32}, {76,0,0}, {234,32,15}]
215+
[{213, 45, 132}, {64, 76, 32}, {76, 0, 0}, {234, 32, 15}]
216216
```
217217

218218
By default, a comprehension returns a list as a result. However the result of a comprehension can be inserted into different data structures by passing the `:into` option. For example, we can use bitstring generators with the `:into` option to easily remove all spaces in a string:

Diff for: crash-course.markdown

+5-5
Original file line numberDiff line numberDiff line change
@@ -162,13 +162,13 @@ Elixir allows you to omit parentheses in function calls, Erlang does not.
162162
Invoking a function from a module uses different syntax. In Erlang, you would write
163163

164164
```erlang
165-
lists:last([1,2]).
165+
lists:last([1, 2]).
166166
```
167167

168168
to invoke the `last` function from the `List` module. In Elixir, use the dot `.` in place of the colon `:`
169169

170170
```elixir
171-
List.last([1,2])
171+
List.last([1, 2])
172172
```
173173

174174
**Note**. Since Erlang modules are represented by atoms, you may invoke Erlang functions in Elixir as follows:
@@ -526,7 +526,7 @@ sum(1, 2).
526526
%=> 3
527527

528528
sum([1], [2]).
529-
%=> [1,2]
529+
%=> [1, 2]
530530

531531
sum("a", "b").
532532
%=> "ab"
@@ -551,7 +551,7 @@ sum 1, 2
551551
#=> 3
552552

553553
sum [1], [2]
554-
#=> [1,2]
554+
#=> [1, 2]
555555

556556
sum "a", "b"
557557
#=> "ab"
@@ -613,7 +613,7 @@ F([]).
613613
%=> "Empty"
614614

615615
F({a, b}).
616-
%=> "All your {a,b} are belong to us"
616+
%=> "All your {a, b} are belong to us"
617617
```
618618

619619
**Elixir**

Diff for: getting-started/basic-operators.markdown

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ In the [previous chapter](/getting-started/basic-types.html), we saw Elixir prov
1212
Elixir also provides `++` and `--` to manipulate lists:
1313

1414
```iex
15-
iex> [1,2,3] ++ [4,5,6]
16-
[1,2,3,4,5,6]
17-
iex> [1,2,3] -- [2]
18-
[1,3]
15+
iex> [1, 2, 3] ++ [4, 5, 6]
16+
[1, 2, 3, 4, 5, 6]
17+
iex> [1, 2, 3] -- [2]
18+
[1, 3]
1919
```
2020

2121
String concatenation is done with `<>`:

Diff for: getting-started/basic-types.markdown

+1-1
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ iex> [1, true, 2, false, 3, true] -- [true, false]
258258
Throughout the tutorial, we will talk a lot about the head and tail of a list. The head is the first element of a list and the tail is the remainder of a list. They can be retrieved with the functions `hd/1` and `tl/1`. Let's assign a list to a variable and retrieve its head and tail:
259259

260260
```iex
261-
iex> list = [1,2,3]
261+
iex> list = [1, 2, 3]
262262
iex> hd(list)
263263
1
264264
iex> tl(list)

Diff for: getting-started/case-cond-and-if.markdown

+1-1
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ Finally, note `cond` considers any value besides `nil` and `false` to be true:
178178

179179
```iex
180180
iex> cond do
181-
...> hd([1,2,3]) ->
181+
...> hd([1, 2, 3]) ->
182182
...> "1 is considered as true"
183183
...> end
184184
"1 is considered as true"

Diff for: getting-started/modules.markdown

+3-3
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,9 @@ defmodule Math do
116116
end
117117
end
118118

119-
IO.puts Math.zero?(0) #=> true
120-
IO.puts Math.zero?(1) #=> false
121-
IO.puts Math.zero?([1,2,3]) #=> ** (FunctionClauseError)
119+
IO.puts Math.zero?(0) #=> true
120+
IO.puts Math.zero?(1) #=> false
121+
IO.puts Math.zero?([1, 2, 3]) #=> ** (FunctionClauseError)
122122
```
123123

124124
Giving an argument that does not match any of the clauses raises an error.

Diff for: getting-started/pattern-matching.markdown

+1-1
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ iex> _
178178
Although pattern matching allows us to build powerful constructs, its usage is limited. For instance, you cannot make function calls on the left side of a match. The following example is invalid:
179179

180180
```iex
181-
iex> length([1,[2],3]) = 3
181+
iex> length([1, [2], 3]) = 3
182182
** (CompileError) iex:1: illegal pattern
183183
```
184184

Diff for: getting-started/protocols.markdown

+2-2
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ Elixir ships with some built-in protocols. In previous chapters, we have discuss
167167

168168
```iex
169169
iex> Enum.map [1, 2, 3], fn(x) -> x * 2 end
170-
[2,4,6]
170+
[2, 4, 6]
171171
iex> Enum.reduce 1..3, 0, fn(x, acc) -> x + acc end
172172
6
173173
```
@@ -205,7 +205,7 @@ The `Inspect` protocol is the protocol used to transform any data structure into
205205

206206
```iex
207207
iex> {1, 2, 3}
208-
{1,2,3}
208+
{1, 2, 3}
209209
iex> %User{}
210210
%User{name: "john", age: 27}
211211
```

Diff for: index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ <h4>Erlang compatible</h4>
168168

169169
{% highlight iex %}
170170
iex> :crypto.md5("Using crypto from Erlang OTP")
171-
<<192,223,75,115,...>>
171+
<<192, 223, 75, 115, ...>>
172172
{% endhighlight %}
173173

174174
<p>To learn more about Elixir, check our <a href="/getting-started/introduction.html">getting started guide</a>. We also have <a href="/docs.html">online documentation available</a> and a <a href="/crash-course.html">Crash Course for Erlang developers</a>.</p>

0 commit comments

Comments
 (0)