/
Enum.html
696 lines (592 loc) · 21.7 KB
/
Enum.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
<!DOCTYPE html>
<html>
<head>
<title>Enum</title>
<meta charset="utf-8">
<link rel="stylesheet" href="css/style.css" type="text/css" media="screen" charset="utf-8" />
<script type="text/javascript" charset="utf-8">
relpath = '';
if (relpath != '') relpath += '/';
</script>
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
<script type="text/javascript" charset="utf-8" src="js/app.js"></script>
</head>
<body>
<script type="text/javascript" charset="utf-8">
if (window.top.frames.main) document.body.className = 'frames';
</script>
<div id="content">
<h1>
Enum
</h1>
<div id="moduledoc" class="docstring">
<p>Provides a set of algorithms that enumerate over collections according to the
<code>Enum.Iterator</code> protocol. Most of the functions in this module have two
flavours. If a given collection implements the mentioned protocol (like
list, for instance), you can do:</p>
<pre><code>Enum.map [1,2,3], fn(x) -> x * 2 end
</code></pre>
<p>Depending on the type of the collection, the user-provided function will
accept a certain type of argument. For dicts, the argument is always a
<code>{ key, value }</code> tuple.</p>
</div>
<a href="https://github.com/elixir-lang/elixir/blob/master/lib/elixir/lib/enum.ex#L55" target="_blank" class="view_source">Source</a>
<h2>Functions summary</h2>
<ul class="summary">
<li>
<span class="summary_signature">
<a href="#all?/2">all?/2</a>
</span>
</li>
<li>
<span class="summary_signature">
<a href="#any?/2">any?/2</a>
</span>
</li>
<li>
<span class="summary_signature">
<a href="#at!/2">at!/2</a>
</span>
</li>
<li>
<span class="summary_signature">
<a href="#count/1">count/1</a>
</span>
</li>
<li>
<span class="summary_signature">
<a href="#count/2">count/2</a>
</span>
</li>
<li>
<span class="summary_signature">
<a href="#drop/2">drop/2</a>
</span>
</li>
<li>
<span class="summary_signature">
<a href="#drop_while/2">drop_while/2</a>
</span>
</li>
<li>
<span class="summary_signature">
<a href="#each/2">each/2</a>
</span>
</li>
<li>
<span class="summary_signature">
<a href="#empty?/1">empty?/1</a>
</span>
</li>
<li>
<span class="summary_signature">
<a href="#filter/2">filter/2</a>
</span>
</li>
<li>
<span class="summary_signature">
<a href="#filter_map/3">filter_map/3</a>
</span>
</li>
<li>
<span class="summary_signature">
<a href="#find/3">find/3</a>
</span>
</li>
<li>
<span class="summary_signature">
<a href="#find_index/2">find_index/2</a>
</span>
</li>
<li>
<span class="summary_signature">
<a href="#find_value/3">find_value/3</a>
</span>
</li>
<li>
<span class="summary_signature">
<a href="#first/1">first/1</a>
</span>
</li>
<li>
<span class="summary_signature">
<a href="#join/2">join/2</a>
</span>
</li>
<li>
<span class="summary_signature">
<a href="#map/2">map/2</a>
</span>
</li>
<li>
<span class="summary_signature">
<a href="#map_join/3">map_join/3</a>
</span>
</li>
<li>
<span class="summary_signature">
<a href="#map_reduce/3">map_reduce/3</a>
</span>
</li>
<li>
<span class="summary_signature">
<a href="#partition/2">partition/2</a>
</span>
</li>
<li>
<span class="summary_signature">
<a href="#reduce/3">reduce/3</a>
</span>
</li>
<li>
<span class="summary_signature">
<a href="#reverse/1">reverse/1</a>
</span>
</li>
<li>
<span class="summary_signature">
<a href="#sort/1">sort/1</a>
</span>
</li>
<li>
<span class="summary_signature">
<a href="#sort/2">sort/2</a>
</span>
</li>
<li>
<span class="summary_signature">
<a href="#split/2">split/2</a>
</span>
</li>
<li>
<span class="summary_signature">
<a href="#split_while/2">split_while/2</a>
</span>
</li>
<li>
<span class="summary_signature">
<a href="#take/2">take/2</a>
</span>
</li>
<li>
<span class="summary_signature">
<a href="#take_while/2">take_while/2</a>
</span>
</li>
<li>
<span class="summary_signature">
<a href="#uniq/1">uniq/1</a>
</span>
</li>
<li>
<span class="summary_signature">
<a href="#zip/2">zip/2</a>
</span>
</li>
</ul>
<div id="functions_details" class="details_list">
<h2>Functions</h2>
<div class="detail">
<p class="signature" id="all?/2">
<strong>all?(collection, fun // fn x -> x end)</strong>
</p>
<div class="docstring"><p>Invokes the given <code>fun</code> for each item in the <code>collection</code> and returns true if
each invocation returns true as well, otherwise it short-circuits and returns
false.</p>
<h2>Examples</h2>
<pre><code>Enum.all? [2,4,6], fn(x) -> rem(x, 2) == 0 end
#=> true
Enum.all? [2,3,4], fn(x) -> rem(x, 2) == 0 end
#=> false
</code></pre>
<p>If no function is given, it defaults to checking if
all items in the collection evaluate to true.</p>
<pre><code>Enum.all? [1,2,3] #=> true
Enum.all? [1,nil,3] #=> false
</code></pre>
</div>
<a href="https://github.com/elixir-lang/elixir/blob/master/lib/elixir/lib/enum.ex#L97" target="_blank" class="view_source">Source</a>
</div><div class="detail">
<p class="signature" id="any?/2">
<strong>any?(collection, fun // fn x -> x end)</strong>
</p>
<div class="docstring"><p>Invokes the given <code>fun</code> for each item in the <code>collection</code> and returns true if
at least one invocation returns true. Returns false otherwise.</p>
<h2>Examples</h2>
<pre><code>Enum.any? [2,4,6], fn(x) -> rem(x, 2) == 1 end
#=> false
Enum.any? [2,3,4], fn(x) -> rem(x, 2) == 1 end
#=> true
</code></pre>
<p>If no function is given, it defaults to checking if
at least one item in the collection evaluates to true.</p>
<pre><code>Enum.any? [false,false,false] #=> false
Enum.any? [false,true,false] #=> true
</code></pre>
</div>
<a href="https://github.com/elixir-lang/elixir/blob/master/lib/elixir/lib/enum.ex#L134" target="_blank" class="view_source">Source</a>
</div><div class="detail">
<p class="signature" id="at!/2">
<strong>at!(collection, n)</strong>
</p>
<div class="docstring"><p>Finds the element at the given index (zero-based).
Raises out of bounds error in case the given position
is outside the range of the collection.</p>
<p>Expects an ordered collection.</p>
<p>## Examples</p>
<pre><code> Enum.at! [2,4,6], 0 #=> 2
Enum.at! [2,4,6], 2 #=> 6
Enum.at! [2,4,6], 4 #=> raises Enum.OutOfBoundsError
</code></pre>
</div>
<a href="https://github.com/elixir-lang/elixir/blob/master/lib/elixir/lib/enum.ex#L164" target="_blank" class="view_source">Source</a>
</div><div class="detail">
<p class="signature" id="count/1">
<strong>count(collection)</strong>
</p>
<div class="docstring"><p>Returns the collection size.</p>
<h2>Examples</h2>
<pre><code>Enum.count [1,2,3] #=> 3
</code></pre>
</div>
<a href="https://github.com/elixir-lang/elixir/blob/master/lib/elixir/lib/enum.ex#L186" target="_blank" class="view_source">Source</a>
</div><div class="detail">
<p class="signature" id="count/2">
<strong>count(collection, fun)</strong>
</p>
<div class="docstring"><p>Counts for how many items the function returns true.</p>
</div>
<a href="https://github.com/elixir-lang/elixir/blob/master/lib/elixir/lib/enum.ex#L194" target="_blank" class="view_source">Source</a>
</div><div class="detail">
<p class="signature" id="drop/2">
<strong>drop(collection, count)</strong>
</p>
<div class="docstring"><p>Drops the first <code>count</code> items from the collection.
Expects an ordered collection.</p>
<h2>Examples</h2>
<pre><code>Enum.drop [1,2,3], 2 #=> [3]
Enum.drop [1,2,3], 10 #=> []
Enum.drop [1,2,3], 0 #=> [1,2,3]
</code></pre>
</div>
<a href="https://github.com/elixir-lang/elixir/blob/master/lib/elixir/lib/enum.ex#L219" target="_blank" class="view_source">Source</a>
</div><div class="detail">
<p class="signature" id="drop_while/2">
<strong>drop_while(collection, fun)</strong>
</p>
<div class="docstring"><p>Drops items at the beginning of <code>collection</code> while <code>fun</code> returns true.
Expects an ordered collection.</p>
<h2>Examples</h2>
<pre><code>Enum.drop_while [1,2,3,4,5], fn(x) -> x < 3 end
#=> [3,4,5]
</code></pre>
</div>
<a href="https://github.com/elixir-lang/elixir/blob/master/lib/elixir/lib/enum.ex#L247" target="_blank" class="view_source">Source</a>
</div><div class="detail">
<p class="signature" id="each/2">
<strong>each(collection, fun)</strong>
</p>
<div class="docstring"><p>Invokes the given <code>fun</code> for each item in the <code>collection</code>.
Returns the <code>collection</code> itself.</p>
<h2>Examples</h2>
<pre><code>Enum.each ['some', 'example'], fn(x) -> IO.puts x end
</code></pre>
</div>
<a href="https://github.com/elixir-lang/elixir/blob/master/lib/elixir/lib/enum.ex#L270" target="_blank" class="view_source">Source</a>
</div><div class="detail">
<p class="signature" id="empty?/1">
<strong>empty?(collection)</strong>
</p>
<div class="docstring"><p>Returns true if the collection is empty, otherwise false.</p>
<h2>Examples</h2>
<pre><code>Enum.empty? [] #=> true
Enum.empty? [1,2,3] #=> false
</code></pre>
</div>
<a href="https://github.com/elixir-lang/elixir/blob/master/lib/elixir/lib/enum.ex#L295" target="_blank" class="view_source">Source</a>
</div><div class="detail">
<p class="signature" id="filter/2">
<strong>filter(collection, fun)</strong>
</p>
<div class="docstring"><p>Filters the collection, i.e. returns only those elements
for which <code>fun</code> returns true.</p>
<h2>Examples</h2>
<pre><code>Enum.filter [1, 2, 3], fn(x) -> rem(x, 2) == 0 end
#=> [2]
</code></pre>
</div>
<a href="https://github.com/elixir-lang/elixir/blob/master/lib/elixir/lib/enum.ex#L317" target="_blank" class="view_source">Source</a>
</div><div class="detail">
<p class="signature" id="filter_map/3">
<strong>filter_map(collection, filter, mapper)</strong>
</p>
<div class="docstring"><p>Filters the collection and maps its values in one pass.</p>
<h2>Examples</h2>
<pre><code>Enum.filter_map [1, 2, 3], fn(x) -> rem(x, 2) == 0 end, &1 * 2
#=> [4]
</code></pre>
</div>
<a href="https://github.com/elixir-lang/elixir/blob/master/lib/elixir/lib/enum.ex#L340" target="_blank" class="view_source">Source</a>
</div><div class="detail">
<p class="signature" id="find/3">
<strong>find(collection, ifnone // nil, fun)</strong>
</p>
<div class="docstring"><p>Returns the first item for which <code>fun</code> returns a truthy value. If no such
item is found, returns <code>ifnone</code>.</p>
<h2>Examples</h2>
<pre><code>Enum.find [2,4,6], fn(x) -> rem(x, 2) == 1 end
#=> nil
Enum.find [2,4,6], 0, fn(x) -> rem(x, 2) == 1 end
#=> 0
Enum.find [2,3,4], fn(x) -> rem(x, 2) == 1 end
#=> 3
</code></pre>
</div>
<a href="https://github.com/elixir-lang/elixir/blob/master/lib/elixir/lib/enum.ex#L372" target="_blank" class="view_source">Source</a>
</div><div class="detail">
<p class="signature" id="find_index/2">
<strong>find_index(collection, fun)</strong>
</p>
<div class="docstring"><p>Similar to find, but returns the index (count starts with 0)
of the item instead of the element itself.</p>
<p>Expects an ordered collection.</p>
<h2>Examples</h2>
<pre><code>Enum.find_index [2,4,6], fn(x) -> rem(x, 2) == 1 end
#=> nil
Enum.find_index [2,3,4], fn(x) -> rem(x, 2) == 1 end
#=> 2
</code></pre>
</div>
<a href="https://github.com/elixir-lang/elixir/blob/master/lib/elixir/lib/enum.ex#L434" target="_blank" class="view_source">Source</a>
</div><div class="detail">
<p class="signature" id="find_value/3">
<strong>find_value(collection, ifnone // nil, fun)</strong>
</p>
<div class="docstring"><p>Similar to find, but returns the value of the function
invocation instead of the element itself.</p>
<h2>Examples</h2>
<pre><code>Enum.find_value [2,4,6], fn(x) -> rem(x, 2) == 1 end
#=> nil
Enum.find_value [2,3,4], fn(x) -> rem(x, 2) == 1 end
#=> true
</code></pre>
</div>
<a href="https://github.com/elixir-lang/elixir/blob/master/lib/elixir/lib/enum.ex#L403" target="_blank" class="view_source">Source</a>
</div><div class="detail">
<p class="signature" id="first/1">
<strong>first(collection)</strong>
</p>
<div class="docstring"><p>Returns the first item in the collection or nil otherwise.</p>
<h2>Examples</h2>
<pre><code>Enum.first [] #=> nil
Enum.first [1,2,3] #=> 1
</code></pre>
</div>
<a href="https://github.com/elixir-lang/elixir/blob/master/lib/elixir/lib/enum.ex#L457" target="_blank" class="view_source">Source</a>
</div><div class="detail">
<p class="signature" id="join/2">
<strong>join(collection, joiner // "")</strong>
</p>
<div class="docstring"><p>Joins the given <code>collection</code> according to <code>joiner</code>.
Joiner can be either a binary or a list and the
result will be of the same type as joiner. If
joiner is not passed at all, it defaults to an
empty binary.</p>
<p>All items in the collection must be convertible
to binary, otherwise an error is raised.</p>
<h2>Examples</h2>
<pre><code>Enum.join([1,2,3]) #=> "123"
Enum.join([1,2,3], " = ") #=> "1 = 2 = 3"
Enum.join([1,2,3], ' = ') #=> '1 = 2 = 3'
</code></pre>
</div>
<a href="https://github.com/elixir-lang/elixir/blob/master/lib/elixir/lib/enum.ex#L487" target="_blank" class="view_source">Source</a>
</div><div class="detail">
<p class="signature" id="map/2">
<strong>map(collection, fun)</strong>
</p>
<div class="docstring"><p>Returns a new collection, where each item is the result
of invoking <code>fun</code> on each corresponding item of <code>collection</code>.
For dicts, the function accepts a key-value tuple.</p>
<h2>Examples</h2>
<pre><code>Enum.map [1, 2, 3], fn(x) -> x * 2 end
#=> [2, 4, 6]
Enum.map [a: 1, b: 2], fn({k, v}) -> { k, -v } end
#=> [a: -1, b: -2]
</code></pre>
</div>
<a href="https://github.com/elixir-lang/elixir/blob/master/lib/elixir/lib/enum.ex#L521" target="_blank" class="view_source">Source</a>
</div><div class="detail">
<p class="signature" id="map_join/3">
<strong>map_join(collection, joiner // "", mapper)</strong>
</p>
<div class="docstring"><p>Maps and joins the given <code>collection</code> in one pass.
Joiner can be either a binary or a list and the
result will be of the same type as joiner. If
joiner is not passed at all, it defaults to an
empty binary.</p>
<p>All items in the collection must be convertible
to binary, otherwise an error is raised.</p>
<h2>Examples</h2>
<pre><code>Enum.map_join([1,2,3], &1 * 2) #=> "246"
Enum.map_join([1,2,3], " = ", &1 * 2) #=> "2 = 4 = 6"
Enum.map_join([1,2,3], ' = ', &1 * 2) #=> '2 = 4 = 6'
</code></pre>
</div>
<a href="https://github.com/elixir-lang/elixir/blob/master/lib/elixir/lib/enum.ex#L553" target="_blank" class="view_source">Source</a>
</div><div class="detail">
<p class="signature" id="map_reduce/3">
<strong>map_reduce(collection, acc, f)</strong>
</p>
<div class="docstring"><p>Invokes the given <code>fun</code> for each item in the <code>collection</code>
while also keeping an accumulator. Returns a tuple where
the first element is the mapped collection and the second
one is the final accumulator.</p>
<p>For dicts, the first tuple element has to be a { key, value }
tuple itself.</p>
<h2>Examples</h2>
<pre><code>Enum.map_reduce [1, 2, 3], 0, fn(x, acc) -> { x * 2, x + acc } end
#=> { [2, 4, 6], 6 }
</code></pre>
</div>
<a href="https://github.com/elixir-lang/elixir/blob/master/lib/elixir/lib/enum.ex#L588" target="_blank" class="view_source">Source</a>
</div><div class="detail">
<p class="signature" id="partition/2">
<strong>partition(collection, fun)</strong>
</p>
<div class="docstring"><p>Partitions <code>collection</code> into two where the first one contains elements
for which <code>fun</code> returns a truthy value, and the second one -- for which <code>fun</code>
returns false or nil.</p>
<h2>Examples</h2>
<pre><code>Enum.partition [1, 2, 3], fn(x) -> rem(x, 2) == 0 end
#=> { [2], [1,3] }
</code></pre>
</div>
<a href="https://github.com/elixir-lang/elixir/blob/master/lib/elixir/lib/enum.ex#L613" target="_blank" class="view_source">Source</a>
</div><div class="detail">
<p class="signature" id="reduce/3">
<strong>reduce(collection, acc, fun)</strong>
</p>
<div class="docstring"><p>Invokes <code>fun</code> for each element in the collection passing that element and the
accumulator <code>acc</code> as arguments. <code>fun</code>'s return value is stored in <code>acc</code>.
Returns the accumulator.</p>
<h2>Examples</h2>
<pre><code>Enum.reduce [1, 2, 3], 0, fn(x, acc) -> x + acc end
#=> 6
</code></pre>
</div>
<a href="https://github.com/elixir-lang/elixir/blob/master/lib/elixir/lib/enum.ex#L638" target="_blank" class="view_source">Source</a>
</div><div class="detail">
<p class="signature" id="reverse/1">
<strong>reverse(collection)</strong>
</p>
<div class="docstring"><p>Reverses the collection.</p>
<h2>Examples</h2>
<pre><code>Enum.reverse [1, 2, 3]
#=> [3, 2, 1]
</code></pre>
</div>
<a href="https://github.com/elixir-lang/elixir/blob/master/lib/elixir/lib/enum.ex#L661" target="_blank" class="view_source">Source</a>
</div><div class="detail">
<p class="signature" id="sort/1">
<strong>sort(collection)</strong>
</p>
<div class="docstring"><p>Sorts the collection using the merge sort algorithm.</p>
<h2>Examples</h2>
<pre><code>Enum.sort [3,2,1] #=> [1,2,3]
</code></pre>
</div>
<a href="https://github.com/elixir-lang/elixir/blob/master/lib/elixir/lib/enum.ex#L698" target="_blank" class="view_source">Source</a>
</div><div class="detail">
<p class="signature" id="sort/2">
<strong>sort(collection, fun)</strong>
</p>
<div class="docstring"><p>Sorts the collection using the merge sort algorithm.</p>
<h2>Examples</h2>
<pre><code>Enum.sort [3,2,1], &1 > &2 #=> [1,2,3]
</code></pre>
</div>
<a href="https://github.com/elixir-lang/elixir/blob/master/lib/elixir/lib/enum.ex#L720" target="_blank" class="view_source">Source</a>
</div><div class="detail">
<p class="signature" id="split/2">
<strong>split(collection, count)</strong>
</p>
<div class="docstring"><p>Splits the enumerable into two collections, leaving <code>count</code>
elements in the first one. If <code>count</code> is a negative number,
it starts couting from the back to the beginning of the
collection.</p>
<p>Be aware that a negative <code>count</code> implies the collection
will be iterate twice. One to calculate the position and
another one to do the actual splitting.</p>
<h2>Examples</h2>
<pre><code>Enum.split [1,2,3], 2 #=> { [1,2], [3] }
Enum.split [1,2,3], 10 #=> { [1,2,3], [] }
Enum.split [1,2,3], 0 #=> { [], [1,2,3] }
Enum.split [1,2,3], -1 #=> { [1,2], [3] }
Enum.split [1,2,3], -5 #=> { [], [1,2,3] }
</code></pre>
</div>
<a href="https://github.com/elixir-lang/elixir/blob/master/lib/elixir/lib/enum.ex#L753" target="_blank" class="view_source">Source</a>
</div><div class="detail">
<p class="signature" id="split_while/2">
<strong>split_while(collection, fun)</strong>
</p>
<div class="docstring"><p>Splits <code>collection</code> at the first element, for which <code>fun</code> returns true.
Expects an ordered collection.</p>
<h2>Examples</h2>
<pre><code>Enum.split_while [1,2,3,4], fn x -> x == 2 end
#=> { [1], [2, 3, 4] }
</code></pre>
</div>
<a href="https://github.com/elixir-lang/elixir/blob/master/lib/elixir/lib/enum.ex#L781" target="_blank" class="view_source">Source</a>
</div><div class="detail">
<p class="signature" id="take/2">
<strong>take(collection, count)</strong>
</p>
<div class="docstring"><p>Takes the first <code>count</code> items from the collection. Expects an ordered
collection.</p>
<h2>Examples</h2>
<pre><code>Enum.take [1,2,3], 2 #=> [1,2]
Enum.take [1,2,3], 10 #=> [1,2,3]
Enum.take [1,2,3], 0 #=> []
</code></pre>
</div>
<a href="https://github.com/elixir-lang/elixir/blob/master/lib/elixir/lib/enum.ex#L806" target="_blank" class="view_source">Source</a>
</div><div class="detail">
<p class="signature" id="take_while/2">
<strong>take_while(collection, fun)</strong>
</p>
<div class="docstring"><p>Takes the items at the beginning of <code>collection</code> while <code>fun</code> returns true.
Expects an ordered collection.</p>
<h2>Examples</h2>
<pre><code>Enum.take_while [1,2,3], fn(x) -> x < 3 end
#=> [1, 2]
</code></pre>
</div>
<a href="https://github.com/elixir-lang/elixir/blob/master/lib/elixir/lib/enum.ex#L835" target="_blank" class="view_source">Source</a>
</div><div class="detail">
<p class="signature" id="uniq/1">
<strong>uniq(collection)</strong>
</p>
<div class="docstring"><p>Iterates the enumerable removing all duplicated items.</p>
<h2>Examples</h2>
<pre><code>Enum.uniq [1,2,3,2,1]
#=> [1, 2, 3]
</code></pre>
</div>
<a href="https://github.com/elixir-lang/elixir/blob/master/lib/elixir/lib/enum.ex#L858" target="_blank" class="view_source">Source</a>
</div><div class="detail">
<p class="signature" id="zip/2">
<strong>zip(coll1, coll2)</strong>
</p>
<div class="docstring"><p>Zips corresponding elements from two collections into one list
of tuples. The number of elements in the resulting list is
dictated by the first enum. In case the second list is shorter,
values are filled with nil.</p>
</div>
<a href="https://github.com/elixir-lang/elixir/blob/master/lib/elixir/lib/enum.ex#L878" target="_blank" class="view_source">Source</a>
</div>
</div>
</div>
</body>
</html>