@@ -3,7 +3,7 @@ layout: getting-started
3
3
title : Erlang libraries
4
4
---
5
5
6
- # {{ page.title }}< span hidden >.</ span >
6
+ # {{ page.title }}
7
7
8
8
{% include toc.html %}
9
9
@@ -69,8 +69,11 @@ time conversion functions.
69
69
``` iex
70
70
iex> :calendar.day_of_the_week(1980, 6, 28)
71
71
6
72
- iex> :calendar.now_to_local_time(:erlang.timestamp)
73
- {{2016, 2, 17}, {22, 4, 55}}
72
+ iex> {date, time} = :calendar.now_to_local_time(:erlang.timestamp)
73
+ iex> date
74
+ {2016, 2, 17}
75
+ iex> time
76
+ {22, 4, 55}
74
77
```
75
78
76
79
## The crypto module
@@ -134,13 +137,14 @@ side-effect.
134
137
135
138
``` iex
136
139
iex> table = :ets.new(:ets_test, [])
137
- iex> :ets.insert(table, {%{name: "China", population: 1_374_000_000}})
138
- iex> :ets.insert(table, {%{name: "India", population: 1_284_000_000}})
139
- iex> :ets.insert(table, {%{name: "USA", population: 322_000_000}})
140
+ # Store as tuples with {name, population}
141
+ iex> :ets.insert(table, {"China", 1_374_000_000})
142
+ iex> :ets.insert(table, {"India", 1_284_000_000})
143
+ iex> :ets.insert(table, {"USA", 322_000_000})
140
144
iex> :ets.i(table)
141
- <1 > {#{name => << "USA">>,population => 322000000} }
142
- <2 > {#{name => << "China">>,population => 1374000000} }
143
- <3 > {#{name => << "India">>,population => 1284000000} }
145
+ <1 > {"USA", 322000000}
146
+ <2 > {"China", 1_374_000_000 }
147
+ <3 > {"India", 1_284_000_000 }
144
148
```
145
149
146
150
## The math module
@@ -168,15 +172,15 @@ that implements (double-ended) FIFO (first-in first-out) queues efficiently:
168
172
iex> q = :queue.new
169
173
iex> q = :queue.in("A", q)
170
174
iex> q = :queue.in("B", q)
171
- iex> q = :queue.in("C", q)
172
- iex> {_, q} = :queue.out(q)
173
- {{ :value, "A"}, {["C"], ["B"]} }
174
- iex> {_ , q} = :queue.out(q)
175
- {{:value, "B"}, {[], ["C"]}}
176
- iex> {_, q} = :queue.out(q)
177
- {{: value, "C"}, {[], []}}
178
- iex> {_, q} = :queue.out(q)
179
- { :empty, {[], []}}
175
+ iex> {value, q} = :queue.out( q)
176
+ iex> value
177
+ {:value, "A"}
178
+ iex> {value , q} = :queue.out(q)
179
+ iex> value
180
+ {:value, "B"}
181
+ iex> { value, q} = :queue.out(q)
182
+ iex> value
183
+ :empty
180
184
```
181
185
182
186
## The rand module
0 commit comments