@@ -21,8 +21,8 @@ defmodule Dict do
21
21
protocol:
22
22
23
23
iex> dict = dict_impl.new
24
- ... > dict = Dict.put(dict, :hello, :world)
25
- ... > dict[:hello]
24
+ iex > dict = Dict.put(dict, :hello, :world)
25
+ iex > dict[:hello]
26
26
:world
27
27
28
28
As well as the `Enumerable` and `Collectable` protocols.
@@ -88,7 +88,7 @@ defmodule Dict do
88
88
## Examples
89
89
90
90
iex> d = Enum.into([a: 1, b: 2], dict_impl.new)
91
- ... > Enum.sort(Dict.keys(d))
91
+ iex > Enum.sort(Dict.keys(d))
92
92
[:a,:b]
93
93
94
94
"""
@@ -104,7 +104,7 @@ defmodule Dict do
104
104
## Examples
105
105
106
106
iex> d = Enum.into([a: 1, b: 2], dict_impl.new)
107
- ... > Enum.sort(Dict.values(d))
107
+ iex > Enum.sort(Dict.values(d))
108
108
[1,2]
109
109
110
110
"""
@@ -119,7 +119,7 @@ defmodule Dict do
119
119
## Examples
120
120
121
121
iex> d = Enum.into([a: 1, b: 2], dict_impl.new)
122
- ... > Dict.size(d)
122
+ iex > Dict.size(d)
123
123
2
124
124
125
125
"""
@@ -205,8 +205,8 @@ defmodule Dict do
205
205
## Examples
206
206
207
207
iex> d = Enum.into([a: 1, b: 2], dict_impl.new)
208
- ... > d = Dict.put(d, :a, 3)
209
- ... > Dict.get(d, :a)
208
+ iex > d = Dict.put(d, :a, 3)
209
+ iex > Dict.get(d, :a)
210
210
3
211
211
212
212
"""
@@ -221,8 +221,8 @@ defmodule Dict do
221
221
## Examples
222
222
223
223
iex> d = Enum.into([a: 1, b: 2], dict_impl.new)
224
- ... > d = Dict.put_new(d, :a, 3)
225
- ... > Dict.get(d, :a)
224
+ iex > d = Dict.put_new(d, :a, 3)
225
+ iex > Dict.get(d, :a)
226
226
1
227
227
228
228
"""
@@ -238,12 +238,12 @@ defmodule Dict do
238
238
## Examples
239
239
240
240
iex> d = Enum.into([a: 1, b: 2], dict_impl.new)
241
- ... > d = Dict.delete(d, :a)
242
- ... > Dict.get(d, :a)
241
+ iex > d = Dict.delete(d, :a)
242
+ iex > Dict.get(d, :a)
243
243
nil
244
244
245
245
iex> d = Enum.into([b: 2], dict_impl.new)
246
- ... > Dict.delete(d, :a) == d
246
+ iex > Dict.delete(d, :a) == d
247
247
true
248
248
249
249
"""
@@ -266,17 +266,17 @@ defmodule Dict do
266
266
## Examples
267
267
268
268
iex> d1 = Enum.into([a: 1, b: 2], dict_impl.new)
269
- ... > d2 = Enum.into([a: 3, d: 4], dict_impl.new)
270
- ... > d = Dict.merge(d1, d2)
271
- ... > [a: Dict.get(d, :a), b: Dict.get(d, :b), d: Dict.get(d, :d)]
269
+ iex > d2 = Enum.into([a: 3, d: 4], dict_impl.new)
270
+ iex > d = Dict.merge(d1, d2)
271
+ iex > [a: Dict.get(d, :a), b: Dict.get(d, :b), d: Dict.get(d, :d)]
272
272
[a: 3, b: 2, d: 4]
273
273
274
274
iex> d1 = Enum.into([a: 1, b: 2], dict_impl.new)
275
- ... > d2 = Enum.into([a: 3, d: 4], dict_impl.new)
276
- ... > d = Dict.merge(d1, d2, fn(_k, v1, v2) ->
275
+ iex > d2 = Enum.into([a: 3, d: 4], dict_impl.new)
276
+ iex > d = Dict.merge(d1, d2, fn(_k, v1, v2) ->
277
277
...> v1 + v2
278
278
...> end)
279
- ... > [a: Dict.get(d, :a), b: Dict.get(d, :b), d: Dict.get(d, :d)]
279
+ iex > [a: Dict.get(d, :a), b: Dict.get(d, :b), d: Dict.get(d, :d)]
280
280
[a: 4, b: 2, d: 4]
281
281
282
282
"""
@@ -301,18 +301,18 @@ defmodule Dict do
301
301
## Examples
302
302
303
303
iex> dict = Enum.into([a: 1], dict_impl.new)
304
- ... > {v, d} = Dict.pop dict, :a
305
- ... > {v, Enum.sort(d)}
304
+ iex > {v, d} = Dict.pop dict, :a
305
+ iex > {v, Enum.sort(d)}
306
306
{1,[]}
307
307
308
308
iex> dict = Enum.into([a: 1], dict_impl.new)
309
- ... > {v, d} = Dict.pop dict, :b
310
- ... > {v, Enum.sort(d)}
309
+ iex > {v, d} = Dict.pop dict, :b
310
+ iex > {v, Enum.sort(d)}
311
311
{nil,[a: 1]}
312
312
313
313
iex> dict = Enum.into([a: 1], dict_impl.new)
314
- ... > {v, d} = Dict.pop dict, :b, 3
315
- ... > {v, Enum.sort(d)}
314
+ iex > {v, d} = Dict.pop dict, :b, 3
315
+ iex > {v, Enum.sort(d)}
316
316
{3,[a: 1]}
317
317
318
318
"""
@@ -328,8 +328,8 @@ defmodule Dict do
328
328
## Examples
329
329
330
330
iex> d = Enum.into([a: 1, b: 2], dict_impl.new)
331
- ... > d = Dict.update!(d, :a, fn(val) -> -val end)
332
- ... > Dict.get(d, :a)
331
+ iex > d = Dict.update!(d, :a, fn(val) -> -val end)
332
+ iex > Dict.get(d, :a)
333
333
-1
334
334
335
335
"""
@@ -346,8 +346,8 @@ defmodule Dict do
346
346
## Examples
347
347
348
348
iex> d = Enum.into([a: 1, b: 2], dict_impl.new)
349
- ... > d = Dict.update(d, :c, 3, fn(val) -> -val end)
350
- ... > Dict.get(d, :c)
349
+ iex > d = Dict.update(d, :c, 3, fn(val) -> -val end)
350
+ iex > Dict.get(d, :c)
351
351
3
352
352
353
353
"""
@@ -366,18 +366,18 @@ defmodule Dict do
366
366
## Examples
367
367
368
368
iex> d = Enum.into([a: 1, b: 2, c: 3, d: 4], dict_impl.new)
369
- ... > { d1, d2 } = Dict.split(d, [:a, :c, :e])
370
- ... > { Dict.to_list(d1) |> Enum.sort, Dict.to_list(d2) |> Enum.sort }
369
+ iex > { d1, d2 } = Dict.split(d, [:a, :c, :e])
370
+ iex > { Dict.to_list(d1) |> Enum.sort, Dict.to_list(d2) |> Enum.sort }
371
371
{ [a: 1, c: 3], [b: 2, d: 4] }
372
372
373
373
iex> d = Enum.into([], dict_impl.new)
374
- ... > { d1, d2 } = Dict.split(d, [:a, :c])
375
- ... > { Dict.to_list(d1), Dict.to_list(d2) }
374
+ iex > { d1, d2 } = Dict.split(d, [:a, :c])
375
+ iex > { Dict.to_list(d1), Dict.to_list(d2) }
376
376
{ [], [] }
377
377
378
378
iex> d = Enum.into([a: 1, b: 2], dict_impl.new)
379
- ... > { d1, d2 } = Dict.split(d, [:a, :b, :c])
380
- ... > { Dict.to_list(d1) |> Enum.sort, Dict.to_list(d2) }
379
+ iex > { d1, d2 } = Dict.split(d, [:a, :b, :c])
380
+ iex > { Dict.to_list(d1) |> Enum.sort, Dict.to_list(d2) }
381
381
{ [a: 1, b: 2], [] }
382
382
383
383
"""
@@ -393,13 +393,13 @@ defmodule Dict do
393
393
## Examples
394
394
395
395
iex> d = Enum.into([a: 1, b: 2], dict_impl.new)
396
- ... > d = Dict.drop(d, [:a, :c, :d])
397
- ... > Dict.to_list(d)
396
+ iex > d = Dict.drop(d, [:a, :c, :d])
397
+ iex > Dict.to_list(d)
398
398
[b: 2]
399
399
400
400
iex> d = Enum.into([a: 1, b: 2], dict_impl.new)
401
- ... > d = Dict.drop(d, [:c, :d])
402
- ... > Dict.to_list(d) |> Enum.sort
401
+ iex > d = Dict.drop(d, [:c, :d])
402
+ iex > Dict.to_list(d) |> Enum.sort
403
403
[a: 1, b: 2]
404
404
405
405
"""
@@ -416,13 +416,11 @@ defmodule Dict do
416
416
## Examples
417
417
418
418
iex> d = Enum.into([a: 1, b: 2], dict_impl.new)
419
- ...>
420
- ...> d = Dict.take(d, [:a, :c, :d])
421
- ...> Dict.to_list(d)
419
+ iex> d = Dict.take(d, [:a, :c, :d])
420
+ iex> Dict.to_list(d)
422
421
[a: 1]
423
- ...>
424
- ...> d = Dict.take(d, [:c, :d])
425
- ...> Dict.to_list(d)
422
+ iex> d = Dict.take(d, [:c, :d])
423
+ iex> Dict.to_list(d)
426
424
[]
427
425
428
426
"""
@@ -447,13 +445,13 @@ defmodule Dict do
447
445
## Examples
448
446
449
447
iex> a = Enum.into([a: 2, b: 3, f: 5, c: 123], dict_impl.new)
450
- ... > b = [a: 2, b: 3, f: 5, c: 123]
451
- ... > Dict.equal?(a, b)
448
+ iex > b = [a: 2, b: 3, f: 5, c: 123]
449
+ iex > Dict.equal?(a, b)
452
450
true
453
451
454
452
iex> a = Enum.into([a: 2, b: 3, f: 5, c: 123], dict_impl.new)
455
- ... > b = []
456
- ... > Dict.equal?(a, b)
453
+ iex > b = []
454
+ iex > Dict.equal?(a, b)
457
455
false
458
456
459
457
"""
0 commit comments