Skip to content

Commit

Permalink
Remove use of single vars in pattern matching (elixirschool#1076)
Browse files Browse the repository at this point in the history
* Replace [h|t] with [head | tail] in Collections

* Remove use of single letter variables and add space around cons operator
  • Loading branch information
eksperimental authored and doomspork committed May 14, 2017
1 parent 1caad67 commit c2ce60b
Show file tree
Hide file tree
Showing 38 changed files with 76 additions and 76 deletions.
6 changes: 3 additions & 3 deletions bg/lessons/basics/collections.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ iex> tl [3.14, :pie, "Apple"]
В допълнение към гореспоменатите функции, може да ползвате [pattern matching](../pattern-matching/) и оператора `|` за да разделите списъка на глава и опашка; ще разгледаме този подход в дълбочина в следващи уроци:

```elixir
iex> [h|t] = [3.14, :pie, "Apple"]
iex> [head | tail] = [3.14, :pie, "Apple"]
[3.14, :pie, "Apple"]
iex> h
iex> head
3.14
iex> t
iex> tail
[:pie, "Apple"]
```

Expand Down
2 changes: 1 addition & 1 deletion bg/lessons/basics/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ end
```elixir
defmodule Length do
def of([]), do: 0
def of([_|t]), do: 1 + of(t)
def of([_ | tail]), do: 1 + of(tail)
end

iex> Length.of []
Expand Down
6 changes: 3 additions & 3 deletions bn/lessons/basics/collections.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ iex> tl [3.14, :pie, "Apple"]
এছাড়াও আমরা [pattern matching](../pattern-matching/) এবং কন্স অপারেটর `|` দিয়েও একটি লিস্টকে দুই ভাগে ভাগ করতে পারি যা সম্পর্কে পরে আলোচনা হবে।

```elixir
iex> [h|t] = [3.14, :pie, "Apple"]
iex> [head | tail] = [3.14, :pie, "Apple"]
[3.14, :pie, "Apple"]
iex> h
iex> head
3.14
iex> t
iex> tail
[:pie, "Apple"]
```

Expand Down
2 changes: 1 addition & 1 deletion bn/lessons/basics/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ end
```elixir
defmodule Length do
def of([]), do: 0
def of([_|t]), do: 1 + of(t)
def of([_ | tail]), do: 1 + of(tail)
end

iex> Length.of []
Expand Down
6 changes: 3 additions & 3 deletions cn/lessons/basics/collections.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ iex> tl [3.14, :pie, "Apple"]
除了上面的提到的函数,你还可以使用[模式匹配(pattern matching)](../pattern-matching/)`|` 操作符来把一个列表分成头尾两部分;我们在后面的教程中还会看到这种用法。

```elixir
iex> [h|t] = [3.14, :pie, "Apple"]
iex> [head | tail] = [3.14, :pie, "Apple"]
[3.14, :pie, "Apple"]
iex> h
iex> head
3.14
iex> t
iex> tail
[:pie, "Apple"]
```

Expand Down
2 changes: 1 addition & 1 deletion cn/lessons/basics/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ end
```elixir
defmodule Length do
def of([]), do: 0
def of([_|t]), do: 1 + of(t)
def of([_ | tail]), do: 1 + of(tail)
end

iex> Length.of []
Expand Down
6 changes: 3 additions & 3 deletions de/lessons/basics/collections.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ iex> tl [3.14, :pie, "Apple"]
Zusätzlich zu den bereits erwähnten Funktionen kannst du [Pattern Matching](../pattern-matching/) und den Cons-Operator `|` dazu benutzen eine Liste in `head` und `tail` zu teilen; wir werden in späteren Kapiteln mehr über dieses Pattern lernen:

```elixir
iex> [h|t] = [3.14, :pie, "Apple"]
iex> [head | tail] = [3.14, :pie, "Apple"]
[3.14, :pie, "Apple"]
iex> h
iex> head
3.14
iex> t
iex> tail
[:pie, "Apple"]
```

Expand Down
2 changes: 1 addition & 1 deletion de/lessons/basics/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ Mit unserem Wissen über pattern matching bewaffnet, lass uns mit Hilfe von bena
```elixir
defmodule Length do
def of([]), do: 0
def of([_|t]), do: 1 + of(t)
def of([_ | tail]), do: 1 + of(tail)
end

iex> Length.of []
Expand Down
6 changes: 3 additions & 3 deletions es/lessons/basics/collections.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ iex> tl [3.14, :pie, "Apple"]
Además de la funciones citadas, puedes usar el operador tubería `|`; veremos este patrón en futuras lecciones:

```elixir
iex> [h|t] = [3.14, :pie, "Apple"]
iex> [head | tail] = [3.14, :pie, "Apple"]
[3.14, :pie, "Apple"]
iex> h
iex> head
3.14
iex> t
iex> tail
[:pie, "Apple"]
```

Expand Down
2 changes: 1 addition & 1 deletion es/lessons/basics/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ Armados con nuestro conocimiento de coincidencia de patrones, vamos a explorar l
```elixir
defmodule Length do
def of([]), do: 0
def of([_|t]), do: 1 + of(t)
def of([_ | tail]), do: 1 + of(tail)
end

iex> Length.of []
Expand Down
6 changes: 3 additions & 3 deletions fr/lessons/basics/collections.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ iex> tl [3.14, :pie, "Apple"]
En plus des fonctions ci-dessus, vous pouvez utiliser un pipe `|` pour déstructurer une liste. Nous verrons cet idiome dans les leçons suivantes:

```elixir
iex> [h|t] = [3.14, :pie, "Apple"]
iex> [head | tail] = [3.14, :pie, "Apple"]
[3.14, :pie, "Apple"]
iex> h
iex> head
3.14
iex> t
iex> tail
[:pie, "Apple"]
```

Expand Down
2 changes: 1 addition & 1 deletion fr/lessons/basics/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ Armés de notre connaissance du pattern matching, explorons maintenant la récur
```elixir
defmodule Length do
def of([]), do: 0
def of([_|t]), do: 1 + of(t)
def of([_ | tail]), do: 1 + of(tail)
end

iex> Length.of []
Expand Down
6 changes: 3 additions & 3 deletions gr/lessons/basics/collections.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ iex> tl [3.41, :pie, "Apple"]
Επιπρόσθετα στις προαναφερθείσες συναρτήσεις, μπορείτε να χρησιμοποιήσετε [αντιπαραβολές προτύπων](../pattern-matching/) και τον τελεστή σωλήνα `|` για να χωρίσετε μια λίστα στην κεφαλή και την ουρά. Θα μάθουμε περισσότερα για αυτό το πρότυπο σε μεταγενέστερα μαθήματα:

```elixir
iex> [h|t] = [3.41, :pie, "Apple"]
iex> [head | tail] = [3.41, :pie, "Apple"]
[3.41, :pie, "Apple"]
iex> h
iex> head
3.41
iex> t
iex> tail
[:pie, "Apple"]
```

Expand Down
2 changes: 1 addition & 1 deletion gr/lessons/basics/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ end
```elixir
defmodule Length do
def of([]), do: 0
def of([_|t]), do: 1 + of(t)
def of([_ | tail]), do: 1 + of(tail)
end

iex> Length.of []
Expand Down
6 changes: 3 additions & 3 deletions id/lessons/basics/collections.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ iex> tl [3.14, :pie, "Apple"]
Di samping kedua fungsi tersebut, anda juga bisa menggunakan operator `|`; kita akan melihat pola ini di pelajaran-pelajaran selanjutnya:

```elixir
iex> [h|t] = [3.14, :pie, "Apple"]
iex> [head | tail] = [3.14, :pie, "Apple"]
[3.14, :pie, "Apple"]
iex> h
iex> head
3.14
iex> t
iex> tail
[:pie, "Apple"]
```

Expand Down
2 changes: 1 addition & 1 deletion id/lessons/basics/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ Dilengkapi dengan pengetahuan kita tentang pencocokan pola, mari kita eksplorasi
```elixir
defmodule Length do
def of([]), do: 0
def of([_|t]), do: 1 + of(t)
def of([_ | tail]), do: 1 + of(tail)
end

iex> Length.of []
Expand Down
6 changes: 3 additions & 3 deletions it/lessons/basics/collections.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ iex> tl [3.14, :pie, "Apple"]
Oltre alle funzioni menzionate in precedenza, puoi usare l'operatore _pipe_ `|`; vedremo questo operatore nelle lezioni successive:

```elixir
iex> [h|t] = [3.14, :pie, "Apple"]
iex> [head | tail] = [3.14, :pie, "Apple"]
[3.14, :pie, "Apple"]
iex> h
iex> head
3.14
iex> t
iex> tail
[:pie, "Apple"]
```

Expand Down
2 changes: 1 addition & 1 deletion it/lessons/basics/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ Dotati delle nozioni sul pattern matching, proviamo ad esplorare la ricorsione u
```elixir
defmodule Length do
def of([]), do: 0
def of([_|t]), do: 1 + of(t)
def of([_ | tail]), do: 1 + of(tail)
end

iex> Length.of []
Expand Down
6 changes: 3 additions & 3 deletions jp/lessons/basics/collections.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ iex> tl [3.14, :pie, "Apple"]
前述した関数に加えて、リストを頭部と尾部に分けるのに[パターンマッチング](../pattern-matching/)やcons演算子(`|`)を使うこともできます。このパターンについては後のレッスンで取り上げます:

```elixir
iex> [h|t] = [3.14, :pie, "Apple"]
iex> [head | tail] = [3.14, :pie, "Apple"]
[3.14, :pie, "Apple"]
iex> h
iex> head
3.14
iex> t
iex> tail
[:pie, "Apple"]
```

Expand Down
2 changes: 1 addition & 1 deletion jp/lessons/basics/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ end
```elixir
defmodule Length do
def of([]), do: 0
def of([_|t]), do: 1 + of(t)
def of([_ | tail]), do: 1 + of(tail)
end

iex> Length.of []
Expand Down
6 changes: 3 additions & 3 deletions ko/lessons/basics/collections.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ iex> tl [3.14, :pie, "Apple"]
> [역주] : `cons`는 Lisp 계열 언어에서 애텀과 리스트를 연결할 때 쓰이는 연산입니다. 첫번째 매개변수로 주어지는 애텀을 두번째 매개변수로 주어지는 리스트의 head 부분에 삽입하게 됩니다. `(cons 1 (2 3)) == (cons 1 (cons 2 (cons 3 nil))))`
```elixir
iex> [h|t] = [3.14, :pie, "Apple"]
iex> [head | tail] = [3.14, :pie, "Apple"]
[3.14, :pie, "Apple"]
iex> h
iex> head
3.14
iex> t
iex> tail
[:pie, "Apple"]
```

Expand Down
2 changes: 1 addition & 1 deletion ko/lessons/basics/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ end
```elixir
defmodule Length do
def of([]), do: 0
def of([_|t]), do: 1 + of(t)
def of([_ | tail]), do: 1 + of(tail)
end

iex> Length.of []
Expand Down
6 changes: 3 additions & 3 deletions lessons/basics/collections.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ iex> tl [3.14, :pie, "Apple"]
In addition to the aforementioned functions, you can use [pattern matching](../pattern-matching/) and the cons operator `|` to split a list into head and tail; we'll learn more about this pattern in later lessons:

```elixir
iex> [h|t] = [3.14, :pie, "Apple"]
iex> [head | tail] = [3.14, :pie, "Apple"]
[3.14, :pie, "Apple"]
iex> h
iex> head
3.14
iex> t
iex> tail
[:pie, "Apple"]
```

Expand Down
2 changes: 1 addition & 1 deletion lessons/basics/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ Armed with our knowledge of pattern matching, let's explore recursion using name
```elixir
defmodule Length do
def of([]), do: 0
def of([_|t]), do: 1 + of(t)
def of([_ | tail]), do: 1 + of(tail)
end

iex> Length.of []
Expand Down
2 changes: 1 addition & 1 deletion lessons/basics/pattern-matching.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ iex> [1|tail] = list
[1, 2, 3]
iex> tail
[2, 3]
iex> [2|_] = list
iex> [2 | _] = list
** (MatchError) no match of right hand side value: [1, 2, 3]

# Tuples
Expand Down
6 changes: 3 additions & 3 deletions my/lessons/basics/collections.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ iex> tl [3.14, :pie, "Apple"]
Sebagai tambahan kepada fungsi-fungsi yang telah disebutkan, anda juga dibenarkan menggunakan aksara paip `|`; kita akan melihat penggunaan corak ini di dalam pelajaran seterusnya:

```elixir
iex> [h|t] = [3.14, :pie, "Apple"]
iex> [head | tail] = [3.14, :pie, "Apple"]
[3.14, :pie, "Apple"]
iex> h
iex> head
3.14
iex> t
iex> tail
[:pie, "Apple"]
```

Expand Down
2 changes: 1 addition & 1 deletion my/lessons/basics/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ Bersedia dengan pengetahuan mengenai pemadanan corak, kita akan meneroka rekursi
```elixir
defmodule Length do
def of([]), do: 0
def of([_|t]), do: 1 + of(t)
def of([_ | tail]), do: 1 + of(tail)
end

iex> Length.of []
Expand Down
6 changes: 3 additions & 3 deletions no/lessons/basics/collections.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ I tillegg til de tidligere nevnte funksjonene, kan vi også bruke
cons operatoren `|` - Vi kommer tilbake til denne operatoren i en senere leksjon:

```elixir
iex> [h|t] = [3.14, :pie, "Apple"]
iex> [head | tail] = [3.14, :pie, "Apple"]
[3.14, :pie, "Apple"]
iex> h
iex> head
3.14
iex> t
iex> tail
[:pie, "Apple"]
```

Expand Down
6 changes: 3 additions & 3 deletions pl/lessons/basics/collections.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ iex> tl [3.14, :pie, "Apple"]
Poza wyżej wymienionymi funkcjami możemy też użyć operatora `|`; spotkamy się z nim w kolejnych lekcjach:

```elixir
iex> [h|t] = [3.14, :pie, "Apple"]
iex> [head | tail] = [3.14, :pie, "Apple"]
[3.14, :pie, "Apple"]
iex> h
iex> head
3.14
iex> t
iex> tail
[:pie, "Apple"]
```

Expand Down
2 changes: 1 addition & 1 deletion pl/lessons/basics/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ Wykorzystując naszą wiedzę o dopasowaniu wzorców, stwórzmy funkcję rekuren
```elixir
defmodule Length do
def of([]), do: 0
def of([_|t]), do: 1 + of(t)
def of([_ | tail]), do: 1 + of(tail)
end

iex> Length.of []
Expand Down
6 changes: 3 additions & 3 deletions pt/lessons/basics/collections.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ iex> tl [3.14, :pie, "Apple"]
Além das funções citadas, pode-se usar [pattern matching](../pattern-matching) e o operador cons `|` para dividir a lista em topo e cauda; veremos este padrão em futuras lições:

```elixir
iex> [h|t] = [3.14, :pie, "Apple"]
iex> [head | tail] = [3.14, :pie, "Apple"]
[3.14, :pie, "Apple"]
iex> h
iex> head
3.14
iex> t
iex> tail
[:pie, "Apple"]
```

Expand Down
2 changes: 1 addition & 1 deletion pt/lessons/basics/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ Armado com nosso conhecimento sobre pattern matching, vamos explorar recursão u
```elixir
defmodule Length do
def of([]), do: 0
def of([_|t]), do: 1 + of(t)
def of([_ | tail]), do: 1 + of(tail)
end

iex> Length.of []
Expand Down
6 changes: 3 additions & 3 deletions ru/lessons/basics/collections.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,11 @@ iex> tl [3.14, :pie, "Apple"]
Того же результата можно добиться с использованием оператора cons — `|`. Мы будем часто его встречать в последующих уроках.

```elixir
iex> [h|t] = [3.14, :pie, "Apple"]
iex> [head | tail] = [3.14, :pie, "Apple"]
[3.14, :pie, "Apple"]
iex> h
iex> head
3.14
iex> t
iex> tail
[:pie, "Apple"]
```

Expand Down
Loading

0 comments on commit c2ce60b

Please sign in to comment.