本文译自 Swift Standard Library: Documented and undocumented built-in functions in the Swift standard library – the complete list with all 74 functions。我不是原作者,我只是勤劳的翻译工:)文中作者没有提及他是如何发现这么多未在文档中体现的内置函数的,估计是反编译的结果。我测试了好多个都能用,而且Xcode还会给出语法提示:)
Swift包含了74个内置函数,但在The Swift Programming Langage
一书中只介绍了其中的7个,其它的都没有在文档中体现。
这篇文章列举出了所有的内置Swift函数。文中所谓的内置函数
是指无需引入任何模块(比如说Fundation
等)即可以直接使用的函数。
下面先来看看7个在文档中提到的内置函数:
<span class="c1" style="color: rgb(117, 113, 94); ">//断言,参数如果为`true`则继续,否则抛出异常
// assert mentioned on page 55
</span><span class="nx" style="color: rgb(166, 226, 46); ">assert</span><span class="p" style="color: rgb(248, 248, 242); ">(</span><span class="kc" style="color: rgb(102, 217, 239); ">true</span><span class="p" style="color: rgb(248, 248, 242); ">)</span>
<span class="c1" style="color: rgb(117, 113, 94); ">//计算序列的元素个数
// countElements mentioned on page 79
</span><span class="nx" style="color: rgb(166, 226, 46); ">countElements</span><span class="p" style="color: rgb(248, 248, 242); ">(</span><span class="s2" style="color: rgb(230, 219, 116); ">"foo"</span><span class="p" style="color: rgb(248, 248, 242); ">)</span> <span class="o" style="color: rgb(249, 38, 114); ">==</span> <span class="mi" style="color: rgb(174, 129, 255); ">3</span>
<span class="c1" style="color: rgb(117, 113, 94); ">//返回一个新的序列,其中每个元素是一个元组,第一个值为原来元素所在的位置`index`,第二个为原来序列中的元素
// enumerate mentioned on page 94
</span><span class="k" style="color: rgb(102, 217, 239); ">for</span> <span class="p" style="color: rgb(248, 248, 242); ">(</span><span class="nx" style="color: rgb(166, 226, 46); ">i</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="nx" style="color: rgb(166, 226, 46); ">j</span><span class="p" style="color: rgb(248, 248, 242); ">)</span> <span class="k" style="color: rgb(102, 217, 239); ">in</span> <span class="nx" style="color: rgb(166, 226, 46); ">enumerate</span><span class="p" style="color: rgb(248, 248, 242); ">([</span><span class="s2" style="color: rgb(230, 219, 116); ">"A"</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="s2" style="color: rgb(230, 219, 116); ">"B"</span><span class="p" style="color: rgb(248, 248, 242); ">])</span> <span class="p" style="color: rgb(248, 248, 242); ">{</span>
<span class="c1" style="color: rgb(117, 113, 94); ">// "0:A", "1:B" will be printed
</span> <span class="nx" style="color: rgb(166, 226, 46); ">println</span><span class="p" style="color: rgb(248, 248, 242); ">(</span><span class="s2" style="color: rgb(230, 219, 116); ">"\(i):\(j)"</span><span class="p" style="color: rgb(248, 248, 242); ">)</span>
<span class="p" style="color: rgb(248, 248, 242); ">}</span>
<span class="c1" style="color: rgb(117, 113, 94); ">//返回所有参数中的最小值
// min mentioned on page 246
</span><span class="nx" style="color: rgb(166, 226, 46); ">min</span><span class="p" style="color: rgb(248, 248, 242); ">(</span><span class="mi" style="color: rgb(174, 129, 255); ">8</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="mi" style="color: rgb(174, 129, 255); ">2</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="mi" style="color: rgb(174, 129, 255); ">3</span><span class="p" style="color: rgb(248, 248, 242); ">)</span> <span class="o" style="color: rgb(249, 38, 114); ">==</span> <span class="mi" style="color: rgb(174, 129, 255); ">2</span>
<span class="c1" style="color: rgb(117, 113, 94); ">//打印
// print mentioned on page 85
</span><span class="nx" style="color: rgb(166, 226, 46); ">print</span><span class="p" style="color: rgb(248, 248, 242); ">(</span><span class="s2" style="color: rgb(230, 219, 116); ">"Hello "</span><span class="p" style="color: rgb(248, 248, 242); ">)</span>
<span class="c1" style="color: rgb(117, 113, 94); ">//打印(带换行)
// println mentioned on page 4
</span><span class="nx" style="color: rgb(166, 226, 46); ">println</span><span class="p" style="color: rgb(248, 248, 242); ">(</span><span class="s2" style="color: rgb(230, 219, 116); ">"World"</span><span class="p" style="color: rgb(248, 248, 242); ">)</span>
<span class="c1" style="color: rgb(117, 113, 94); ">//排序
// sort mentioned on page 14
</span><span class="k" style="color: rgb(102, 217, 239); ">for</span> <span class="nx" style="color: rgb(166, 226, 46); ">i</span> <span class="k" style="color: rgb(102, 217, 239); ">in</span> <span class="nx" style="color: rgb(166, 226, 46); ">sort</span><span class="p" style="color: rgb(248, 248, 242); ">([</span><span class="s2" style="color: rgb(230, 219, 116); ">"B"</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="s2" style="color: rgb(230, 219, 116); ">"A"</span><span class="p" style="color: rgb(248, 248, 242); ">])</span> <span class="p" style="color: rgb(248, 248, 242); ">{</span>
<span class="c1" style="color: rgb(117, 113, 94); ">// "A", "B" will be printed
</span> <span class="nx" style="color: rgb(166, 226, 46); ">println</span><span class="p" style="color: rgb(248, 248, 242); ">(</span><span class="nx" style="color: rgb(166, 226, 46); ">i</span><span class="p" style="color: rgb(248, 248, 242); ">)</span>
<span class="p" style="color: rgb(248, 248, 242); ">}</span>
下面列出一些很实用,但未在文档中体现的内置函数:
- abs(signedNumber):返回数字的绝对值
<span class="nx" style="color: rgb(166, 226, 46); ">abs</span><span class="p" style="color: rgb(248, 248, 242); ">(</span><span class="o" style="color: rgb(249, 38, 114); ">-</span><span class="mi" style="color: rgb(174, 129, 255); ">1</span><span class="p" style="color: rgb(248, 248, 242); ">)</span> <span class="o" style="color: rgb(249, 38, 114); ">==</span> <span class="mi" style="color: rgb(174, 129, 255); ">1</span>
<span class="nx" style="color: rgb(166, 226, 46); ">abs</span><span class="p" style="color: rgb(248, 248, 242); ">(</span><span class="o" style="color: rgb(249, 38, 114); ">-</span><span class="mi" style="color: rgb(174, 129, 255); ">42</span><span class="p" style="color: rgb(248, 248, 242); ">)</span> <span class="o" style="color: rgb(249, 38, 114); ">==</span> <span class="mi" style="color: rgb(174, 129, 255); ">42</span>
<span class="nx" style="color: rgb(166, 226, 46); ">abs</span><span class="p" style="color: rgb(248, 248, 242); ">(</span><span class="mi" style="color: rgb(174, 129, 255); ">42</span><span class="p" style="color: rgb(248, 248, 242); ">)</span> <span class="o" style="color: rgb(249, 38, 114); ">==</span> <span class="mi" style="color: rgb(174, 129, 255); ">42</span>
- contains(sequence, element):如果某个序列
sequence
(比如说一个数组)包含指定的元素element
,则返回true
,否则返回false
。
<span class="kd" style="color: rgb(102, 217, 239); ">var</span> <span class="nx" style="color: rgb(166, 226, 46); ">languages</span> <span class="o" style="color: rgb(249, 38, 114); ">=</span> <span class="p" style="color: rgb(248, 248, 242); ">[</span><span class="s2" style="color: rgb(230, 219, 116); ">"Swift"</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="s2" style="color: rgb(230, 219, 116); ">"Objective-C"</span><span class="p" style="color: rgb(248, 248, 242); ">]</span>
<span class="nx" style="color: rgb(166, 226, 46); ">contains</span><span class="p" style="color: rgb(248, 248, 242); ">(</span><span class="nx" style="color: rgb(166, 226, 46); ">languages</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="s2" style="color: rgb(230, 219, 116); ">"Swift"</span><span class="p" style="color: rgb(248, 248, 242); ">)</span> <span class="o" style="color: rgb(249, 38, 114); ">==</span> <span class="kc" style="color: rgb(102, 217, 239); ">true</span>
<span class="nx" style="color: rgb(166, 226, 46); ">contains</span><span class="p" style="color: rgb(248, 248, 242); ">(</span><span class="nx" style="color: rgb(166, 226, 46); ">languages</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="s2" style="color: rgb(230, 219, 116); ">"Java"</span><span class="p" style="color: rgb(248, 248, 242); ">)</span> <span class="o" style="color: rgb(249, 38, 114); ">==</span> <span class="kc" style="color: rgb(102, 217, 239); ">false</span>
<span class="nx" style="color: rgb(166, 226, 46); ">contains</span><span class="p" style="color: rgb(248, 248, 242); ">([</span><span class="mi" style="color: rgb(174, 129, 255); ">29</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="mi" style="color: rgb(174, 129, 255); ">85</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="mi" style="color: rgb(174, 129, 255); ">42</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="mi" style="color: rgb(174, 129, 255); ">96</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="mi" style="color: rgb(174, 129, 255); ">75</span><span class="p" style="color: rgb(248, 248, 242); ">],</span> <span class="mi" style="color: rgb(174, 129, 255); ">42</span><span class="p" style="color: rgb(248, 248, 242); ">)</span> <span class="o" style="color: rgb(249, 38, 114); ">==</span> <span class="kc" style="color: rgb(102, 217, 239); ">true</span>
- dropFirst(sequence):返回一个去掉了首个元素的、新的序列(比如一个新数组)。
<span class="kd" style="color: rgb(102, 217, 239); ">var</span> <span class="nx" style="color: rgb(166, 226, 46); ">languages</span> <span class="o" style="color: rgb(249, 38, 114); ">=</span> <span class="p" style="color: rgb(248, 248, 242); ">[</span><span class="s2" style="color: rgb(230, 219, 116); ">"Swift"</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="s2" style="color: rgb(230, 219, 116); ">"Objective-C"</span><span class="p" style="color: rgb(248, 248, 242); ">]</span>
<span class="kd" style="color: rgb(102, 217, 239); ">var</span> <span class="nx" style="color: rgb(166, 226, 46); ">oldLanguages</span> <span class="o" style="color: rgb(249, 38, 114); ">=</span> <span class="nx" style="color: rgb(166, 226, 46); ">dropFirst</span><span class="p" style="color: rgb(248, 248, 242); ">(</span><span class="nx" style="color: rgb(166, 226, 46); ">languages</span><span class="p" style="color: rgb(248, 248, 242); ">)</span>
<span class="nx" style="color: rgb(166, 226, 46); ">equal</span><span class="p" style="color: rgb(248, 248, 242); ">(</span><span class="nx" style="color: rgb(166, 226, 46); ">oldLanguages</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="p" style="color: rgb(248, 248, 242); ">[</span><span class="s2" style="color: rgb(230, 219, 116); ">"Objective-C"</span><span class="p" style="color: rgb(248, 248, 242); ">])</span> <span class="o" style="color: rgb(249, 38, 114); ">==</span> <span class="kc" style="color: rgb(102, 217, 239); ">true</span>
- dropLast(sequence):返回一个去掉了最后一个元素的、新的序列(比如一个新数组)。
<span class="kd" style="color: rgb(102, 217, 239); ">var</span> <span class="nx" style="color: rgb(166, 226, 46); ">languages</span> <span class="o" style="color: rgb(249, 38, 114); ">=</span> <span class="p" style="color: rgb(248, 248, 242); ">[</span><span class="s2" style="color: rgb(230, 219, 116); ">"Swift"</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="s2" style="color: rgb(230, 219, 116); ">"Objective-C"</span><span class="p" style="color: rgb(248, 248, 242); ">]</span>
<span class="kd" style="color: rgb(102, 217, 239); ">var</span> <span class="nx" style="color: rgb(166, 226, 46); ">newLanguages</span> <span class="o" style="color: rgb(249, 38, 114); ">=</span> <span class="nx" style="color: rgb(166, 226, 46); ">dropLast</span><span class="p" style="color: rgb(248, 248, 242); ">(</span><span class="nx" style="color: rgb(166, 226, 46); ">languages</span><span class="p" style="color: rgb(248, 248, 242); ">)</span>
<span class="nx" style="color: rgb(166, 226, 46); ">equal</span><span class="p" style="color: rgb(248, 248, 242); ">(</span><span class="nx" style="color: rgb(166, 226, 46); ">newLanguages</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="p" style="color: rgb(248, 248, 242); ">[</span><span class="s2" style="color: rgb(230, 219, 116); ">"Swift"</span><span class="p" style="color: rgb(248, 248, 242); ">])</span> <span class="o" style="color: rgb(249, 38, 114); ">==</span> <span class="kc" style="color: rgb(102, 217, 239); ">true</span>
- dump(object):打印出某个对象
object
的所有信息
<span class="kd" style="color: rgb(102, 217, 239); ">var</span> <span class="nx" style="color: rgb(166, 226, 46); ">languages</span> <span class="o" style="color: rgb(249, 38, 114); ">=</span> <span class="p" style="color: rgb(248, 248, 242); ">[</span><span class="s2" style="color: rgb(230, 219, 116); ">"Swift"</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="s2" style="color: rgb(230, 219, 116); ">"Objective-C"</span><span class="p" style="color: rgb(248, 248, 242); ">]</span>
<span class="nx" style="color: rgb(166, 226, 46); ">dump</span><span class="p" style="color: rgb(248, 248, 242); ">(</span><span class="nx" style="color: rgb(166, 226, 46); ">languages</span><span class="p" style="color: rgb(248, 248, 242); ">)</span>
<span class="c1" style="color: rgb(117, 113, 94); ">// Prints:
// ▿ 2 elements
// - [0]: Swift
// - [1]: Objective-C
</span>
- equal(sequence1, sequence2):判断两个序列是否相等
<span class="kd" style="color: rgb(102, 217, 239); ">var</span> <span class="nx" style="color: rgb(166, 226, 46); ">languages</span> <span class="o" style="color: rgb(249, 38, 114); ">=</span> <span class="p" style="color: rgb(248, 248, 242); ">[</span><span class="s2" style="color: rgb(230, 219, 116); ">"Swift"</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="s2" style="color: rgb(230, 219, 116); ">"Objective-C"</span><span class="p" style="color: rgb(248, 248, 242); ">]</span>
<span class="nx" style="color: rgb(166, 226, 46); ">equal</span><span class="p" style="color: rgb(248, 248, 242); ">(</span><span class="nx" style="color: rgb(166, 226, 46); ">languages</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="p" style="color: rgb(248, 248, 242); ">[</span><span class="s2" style="color: rgb(230, 219, 116); ">"Swift"</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="s2" style="color: rgb(230, 219, 116); ">"Objective-C"</span><span class="p" style="color: rgb(248, 248, 242); ">])</span> <span class="o" style="color: rgb(249, 38, 114); ">==</span> <span class="kc" style="color: rgb(102, 217, 239); ">true</span>
<span class="kd" style="color: rgb(102, 217, 239); ">var</span> <span class="nx" style="color: rgb(166, 226, 46); ">oldLanguages</span> <span class="o" style="color: rgb(249, 38, 114); ">=</span> <span class="nx" style="color: rgb(166, 226, 46); ">dropFirst</span><span class="p" style="color: rgb(248, 248, 242); ">(</span><span class="nx" style="color: rgb(166, 226, 46); ">languages</span><span class="p" style="color: rgb(248, 248, 242); ">)</span>
<span class="nx" style="color: rgb(166, 226, 46); ">equal</span><span class="p" style="color: rgb(248, 248, 242); ">(</span><span class="nx" style="color: rgb(166, 226, 46); ">oldLanguages</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="p" style="color: rgb(248, 248, 242); ">[</span><span class="s2" style="color: rgb(230, 219, 116); ">"Objective-C"</span><span class="p" style="color: rgb(248, 248, 242); ">])</span> <span class="o" style="color: rgb(249, 38, 114); ">==</span> <span class="kc" style="color: rgb(102, 217, 239); ">true</span>
- filter(sequence, includeElementClosure):对序列
sequence
中每个元素都执行includeElementClosure
闭包,并将所有闭包结果为true
的元素合成一个新序列sequence
并返回。
<span class="k" style="color: rgb(102, 217, 239); ">for</span> <span class="nx" style="color: rgb(166, 226, 46); ">i</span> <span class="k" style="color: rgb(102, 217, 239); ">in</span> <span class="nx" style="color: rgb(166, 226, 46); ">filter</span><span class="p" style="color: rgb(248, 248, 242); ">(</span><span class="mi" style="color: rgb(174, 129, 255); ">1</span><span class="p" style="color: rgb(248, 248, 242); ">...</span><span class="mi" style="color: rgb(174, 129, 255); ">100</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="p" style="color: rgb(248, 248, 242); ">{</span> <span class="nx" style="color: rgb(166, 226, 46); ">$0</span> <span class="o" style="color: rgb(249, 38, 114); ">%</span> <span class="mi" style="color: rgb(174, 129, 255); ">10</span> <span class="o" style="color: rgb(249, 38, 114); ">==</span> <span class="mi" style="color: rgb(174, 129, 255); ">0</span> <span class="p" style="color: rgb(248, 248, 242); ">})</span> <span class="p" style="color: rgb(248, 248, 242); ">{</span>
<span class="c1" style="color: rgb(117, 113, 94); ">// 10, 20, 30, ...
</span> <span class="nx" style="color: rgb(166, 226, 46); ">println</span><span class="p" style="color: rgb(248, 248, 242); ">(</span><span class="nx" style="color: rgb(166, 226, 46); ">i</span><span class="p" style="color: rgb(248, 248, 242); ">)</span>
<span class="nx" style="color: rgb(166, 226, 46); ">assert</span><span class="p" style="color: rgb(248, 248, 242); ">(</span><span class="nx" style="color: rgb(166, 226, 46); ">contains</span><span class="p" style="color: rgb(248, 248, 242); ">([</span><span class="mi" style="color: rgb(174, 129, 255); ">10</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="mi" style="color: rgb(174, 129, 255); ">20</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="mi" style="color: rgb(174, 129, 255); ">30</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="mi" style="color: rgb(174, 129, 255); ">40</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="mi" style="color: rgb(174, 129, 255); ">50</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="mi" style="color: rgb(174, 129, 255); ">60</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="mi" style="color: rgb(174, 129, 255); ">70</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="mi" style="color: rgb(174, 129, 255); ">80</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="mi" style="color: rgb(174, 129, 255); ">90</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="mi" style="color: rgb(174, 129, 255); ">100</span><span class="p" style="color: rgb(248, 248, 242); ">],</span> <span class="nx" style="color: rgb(166, 226, 46); ">i</span><span class="p" style="color: rgb(248, 248, 242); ">))</span>
<span class="p" style="color: rgb(248, 248, 242); ">}</span>
- find(sequence, element):返回序列
sequence
中某元素element
的位置index
。如果序列中不存在此元素,则返回nil
。
<span class="kd" style="color: rgb(102, 217, 239); ">var</span> <span class="nx" style="color: rgb(166, 226, 46); ">languages</span> <span class="o" style="color: rgb(249, 38, 114); ">=</span> <span class="p" style="color: rgb(248, 248, 242); ">[</span><span class="s2" style="color: rgb(230, 219, 116); ">"Swift"</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="s2" style="color: rgb(230, 219, 116); ">"Objective-C"</span><span class="p" style="color: rgb(248, 248, 242); ">]</span>
<span class="nx" style="color: rgb(166, 226, 46); ">find</span><span class="p" style="color: rgb(248, 248, 242); ">(</span><span class="nx" style="color: rgb(166, 226, 46); ">languages</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="s2" style="color: rgb(230, 219, 116); ">"Objective-C"</span><span class="p" style="color: rgb(248, 248, 242); ">)</span> <span class="o" style="color: rgb(249, 38, 114); ">==</span> <span class="mi" style="color: rgb(174, 129, 255); ">1</span>
<span class="nx" style="color: rgb(166, 226, 46); ">find</span><span class="p" style="color: rgb(248, 248, 242); ">(</span><span class="nx" style="color: rgb(166, 226, 46); ">languages</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="s2" style="color: rgb(230, 219, 116); ">"Java"</span><span class="p" style="color: rgb(248, 248, 242); ">)</span> <span class="o" style="color: rgb(249, 38, 114); ">==</span> <span class="nx" style="color: rgb(166, 226, 46); ">nil</span>
<span class="nx" style="color: rgb(166, 226, 46); ">find</span><span class="p" style="color: rgb(248, 248, 242); ">([</span><span class="mi" style="color: rgb(174, 129, 255); ">29</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="mi" style="color: rgb(174, 129, 255); ">85</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="mi" style="color: rgb(174, 129, 255); ">42</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="mi" style="color: rgb(174, 129, 255); ">96</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="mi" style="color: rgb(174, 129, 255); ">75</span><span class="p" style="color: rgb(248, 248, 242); ">],</span> <span class="mi" style="color: rgb(174, 129, 255); ">42</span><span class="p" style="color: rgb(248, 248, 242); ">)</span> <span class="o" style="color: rgb(249, 38, 114); ">==</span> <span class="mi" style="color: rgb(174, 129, 255); ">2</span>
- indices(sequence):返回序列
sequence
中所有元素的位置(indices
是index
的复数)
<span class="nx" style="color: rgb(166, 226, 46); ">equal</span><span class="p" style="color: rgb(248, 248, 242); ">(</span><span class="nx" style="color: rgb(166, 226, 46); ">indices</span><span class="p" style="color: rgb(248, 248, 242); ">([</span><span class="mi" style="color: rgb(174, 129, 255); ">29</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="mi" style="color: rgb(174, 129, 255); ">85</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="mi" style="color: rgb(174, 129, 255); ">42</span><span class="p" style="color: rgb(248, 248, 242); ">]),</span> <span class="p" style="color: rgb(248, 248, 242); ">[</span><span class="mi" style="color: rgb(174, 129, 255); ">0</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="mi" style="color: rgb(174, 129, 255); ">1</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="mi" style="color: rgb(174, 129, 255); ">2</span><span class="p" style="color: rgb(248, 248, 242); ">])</span>
<span class="k" style="color: rgb(102, 217, 239); ">for</span> <span class="nx" style="color: rgb(166, 226, 46); ">i</span> <span class="k" style="color: rgb(102, 217, 239); ">in</span> <span class="nx" style="color: rgb(166, 226, 46); ">indices</span><span class="p" style="color: rgb(248, 248, 242); ">([</span><span class="mi" style="color: rgb(174, 129, 255); ">29</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="mi" style="color: rgb(174, 129, 255); ">85</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="mi" style="color: rgb(174, 129, 255); ">42</span><span class="p" style="color: rgb(248, 248, 242); ">])</span> <span class="p" style="color: rgb(248, 248, 242); ">{</span>
<span class="c1" style="color: rgb(117, 113, 94); ">// 0, 1, 2
</span> <span class="nx" style="color: rgb(166, 226, 46); ">println</span><span class="p" style="color: rgb(248, 248, 242); ">(</span><span class="nx" style="color: rgb(166, 226, 46); ">i</span><span class="p" style="color: rgb(248, 248, 242); ">)</span>
<span class="p" style="color: rgb(248, 248, 242); ">}</span>
- join(separator, sequence):将序列
sequence
通过分隔符separator
连成一个字符串,并返回此字符串。
<span class="nx" style="color: rgb(166, 226, 46); ">join</span><span class="p" style="color: rgb(248, 248, 242); ">(</span><span class="s2" style="color: rgb(230, 219, 116); ">":"</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="p" style="color: rgb(248, 248, 242); ">[</span><span class="s2" style="color: rgb(230, 219, 116); ">"A"</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="s2" style="color: rgb(230, 219, 116); ">"B"</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="s2" style="color: rgb(230, 219, 116); ">"C"</span><span class="p" style="color: rgb(248, 248, 242); ">])</span> <span class="o" style="color: rgb(249, 38, 114); ">==</span> <span class="s2" style="color: rgb(230, 219, 116); ">"A:B:C"</span>
<span class="kd" style="color: rgb(102, 217, 239); ">var</span> <span class="nx" style="color: rgb(166, 226, 46); ">languages</span> <span class="o" style="color: rgb(249, 38, 114); ">=</span> <span class="p" style="color: rgb(248, 248, 242); ">[</span><span class="s2" style="color: rgb(230, 219, 116); ">"Swift"</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="s2" style="color: rgb(230, 219, 116); ">"Objective-C"</span><span class="p" style="color: rgb(248, 248, 242); ">]</span>
<span class="nx" style="color: rgb(166, 226, 46); ">join</span><span class="p" style="color: rgb(248, 248, 242); ">(</span><span class="s2" style="color: rgb(230, 219, 116); ">"/"</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="nx" style="color: rgb(166, 226, 46); ">languages</span><span class="p" style="color: rgb(248, 248, 242); ">)</span> <span class="o" style="color: rgb(249, 38, 114); ">==</span> <span class="s2" style="color: rgb(230, 219, 116); ">"Swift/Objective-C"</span>
- map(sequence, transformClosure):对序列
sequence
中每个元素都执行includeElementClosure
闭包,并将所有闭包的结果合成一个新序列sequence
并返回。
<span class="nx" style="color: rgb(166, 226, 46); ">equal</span><span class="p" style="color: rgb(248, 248, 242); ">(</span><span class="nx" style="color: rgb(166, 226, 46); ">map</span><span class="p" style="color: rgb(248, 248, 242); ">(</span><span class="mi" style="color: rgb(174, 129, 255); ">1</span><span class="p" style="color: rgb(248, 248, 242); ">...</span><span class="mi" style="color: rgb(174, 129, 255); ">3</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="p" style="color: rgb(248, 248, 242); ">{</span> <span class="nx" style="color: rgb(166, 226, 46); ">$0</span> <span class="o" style="color: rgb(249, 38, 114); ">*</span> <span class="mi" style="color: rgb(174, 129, 255); ">5</span> <span class="p" style="color: rgb(248, 248, 242); ">}),</span> <span class="p" style="color: rgb(248, 248, 242); ">[</span><span class="mi" style="color: rgb(174, 129, 255); ">5</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="mi" style="color: rgb(174, 129, 255); ">10</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="mi" style="color: rgb(174, 129, 255); ">15</span><span class="p" style="color: rgb(248, 248, 242); ">])</span>
<span class="k" style="color: rgb(102, 217, 239); ">for</span> <span class="nx" style="color: rgb(166, 226, 46); ">i</span> <span class="k" style="color: rgb(102, 217, 239); ">in</span> <span class="nx" style="color: rgb(166, 226, 46); ">map</span><span class="p" style="color: rgb(248, 248, 242); ">(</span><span class="mi" style="color: rgb(174, 129, 255); ">1</span><span class="p" style="color: rgb(248, 248, 242); ">...</span><span class="mi" style="color: rgb(174, 129, 255); ">10</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="p" style="color: rgb(248, 248, 242); ">{</span> <span class="nx" style="color: rgb(166, 226, 46); ">$0</span> <span class="o" style="color: rgb(249, 38, 114); ">*</span> <span class="mi" style="color: rgb(174, 129, 255); ">10</span> <span class="p" style="color: rgb(248, 248, 242); ">})</span> <span class="p" style="color: rgb(248, 248, 242); ">{</span>
<span class="c1" style="color: rgb(117, 113, 94); ">// 10, 20, 30, ...
</span> <span class="nx" style="color: rgb(166, 226, 46); ">println</span><span class="p" style="color: rgb(248, 248, 242); ">(</span><span class="nx" style="color: rgb(166, 226, 46); ">i</span><span class="p" style="color: rgb(248, 248, 242); ">)</span>
<span class="nx" style="color: rgb(166, 226, 46); ">assert</span><span class="p" style="color: rgb(248, 248, 242); ">(</span><span class="nx" style="color: rgb(166, 226, 46); ">contains</span><span class="p" style="color: rgb(248, 248, 242); ">([</span><span class="mi" style="color: rgb(174, 129, 255); ">10</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="mi" style="color: rgb(174, 129, 255); ">20</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="mi" style="color: rgb(174, 129, 255); ">30</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="mi" style="color: rgb(174, 129, 255); ">40</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="mi" style="color: rgb(174, 129, 255); ">50</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="mi" style="color: rgb(174, 129, 255); ">60</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="mi" style="color: rgb(174, 129, 255); ">70</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="mi" style="color: rgb(174, 129, 255); ">80</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="mi" style="color: rgb(174, 129, 255); ">90</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="mi" style="color: rgb(174, 129, 255); ">100</span><span class="p" style="color: rgb(248, 248, 242); ">],</span> <span class="nx" style="color: rgb(166, 226, 46); ">i</span><span class="p" style="color: rgb(248, 248, 242); ">))</span>
<span class="p" style="color: rgb(248, 248, 242); ">}</span>
- max(comparable1, comparable2, etc.):返回参数中的最大值。
<span class="nx" style="color: rgb(166, 226, 46); ">max</span><span class="p" style="color: rgb(248, 248, 242); ">(</span><span class="mi" style="color: rgb(174, 129, 255); ">0</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="mi" style="color: rgb(174, 129, 255); ">1</span><span class="p" style="color: rgb(248, 248, 242); ">)</span> <span class="o" style="color: rgb(249, 38, 114); ">==</span> <span class="mi" style="color: rgb(174, 129, 255); ">1</span>
<span class="nx" style="color: rgb(166, 226, 46); ">max</span><span class="p" style="color: rgb(248, 248, 242); ">(</span><span class="mi" style="color: rgb(174, 129, 255); ">8</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="mi" style="color: rgb(174, 129, 255); ">2</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="mi" style="color: rgb(174, 129, 255); ">3</span><span class="p" style="color: rgb(248, 248, 242); ">)</span> <span class="o" style="color: rgb(249, 38, 114); ">==</span> <span class="mi" style="color: rgb(174, 129, 255); ">8</span>
- maxElement(sequence):返回序列
sequence
中的最大值。
<span class="nx" style="color: rgb(166, 226, 46); ">maxElement</span><span class="p" style="color: rgb(248, 248, 242); ">(</span><span class="mi" style="color: rgb(174, 129, 255); ">1</span><span class="p" style="color: rgb(248, 248, 242); ">...</span><span class="mi" style="color: rgb(174, 129, 255); ">10</span><span class="p" style="color: rgb(248, 248, 242); ">)</span> <span class="o" style="color: rgb(249, 38, 114); ">==</span> <span class="mi" style="color: rgb(174, 129, 255); ">10</span>
<span class="kd" style="color: rgb(102, 217, 239); ">var</span> <span class="nx" style="color: rgb(166, 226, 46); ">languages</span> <span class="o" style="color: rgb(249, 38, 114); ">=</span> <span class="p" style="color: rgb(248, 248, 242); ">[</span><span class="s2" style="color: rgb(230, 219, 116); ">"Swift"</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="s2" style="color: rgb(230, 219, 116); ">"Objective-C"</span><span class="p" style="color: rgb(248, 248, 242); ">]</span>
<span class="nx" style="color: rgb(166, 226, 46); ">maxElement</span><span class="p" style="color: rgb(248, 248, 242); ">(</span><span class="nx" style="color: rgb(166, 226, 46); ">languages</span><span class="p" style="color: rgb(248, 248, 242); ">)</span> <span class="o" style="color: rgb(249, 38, 114); ">==</span> <span class="s2" style="color: rgb(230, 219, 116); ">"Swift"</span>
- minElements(sequence):返回序列
sequence
中的最小值。
<span class="nx" style="color: rgb(166, 226, 46); ">minElement</span><span class="p" style="color: rgb(248, 248, 242); ">(</span><span class="mi" style="color: rgb(174, 129, 255); ">1</span><span class="p" style="color: rgb(248, 248, 242); ">...</span><span class="mi" style="color: rgb(174, 129, 255); ">10</span><span class="p" style="color: rgb(248, 248, 242); ">)</span> <span class="o" style="color: rgb(249, 38, 114); ">==</span> <span class="mi" style="color: rgb(174, 129, 255); ">1</span>
<span class="kd" style="color: rgb(102, 217, 239); ">var</span> <span class="nx" style="color: rgb(166, 226, 46); ">languages</span> <span class="o" style="color: rgb(249, 38, 114); ">=</span> <span class="p" style="color: rgb(248, 248, 242); ">[</span><span class="s2" style="color: rgb(230, 219, 116); ">"Swift"</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="s2" style="color: rgb(230, 219, 116); ">"Objective-C"</span><span class="p" style="color: rgb(248, 248, 242); ">]</span>
<span class="nx" style="color: rgb(166, 226, 46); ">minElement</span><span class="p" style="color: rgb(248, 248, 242); ">(</span><span class="nx" style="color: rgb(166, 226, 46); ">languages</span><span class="p" style="color: rgb(248, 248, 242); ">)</span> <span class="o" style="color: rgb(249, 38, 114); ">==</span> <span class="s2" style="color: rgb(230, 219, 116); ">"Objective-C"</span>
- reduce(sequence, initial, combineClosure):给定一个序列
sequence
,以及一个初始值initial
,然后将initial
和序列里的第1个元素作为参数传入combineClosure
中进行运算,得到的结果保存到initial
;然后再将initial
和第2个元素传入combineClosure
中计算,结果保存到initial
;重复计算直到所有sequence
中的元素都计算完毕,并返回最终的initial
值。
<span class="kd" style="color: rgb(102, 217, 239); ">var</span> <span class="nx" style="color: rgb(166, 226, 46); ">languages</span> <span class="o" style="color: rgb(249, 38, 114); ">=</span> <span class="p" style="color: rgb(248, 248, 242); ">[</span><span class="s2" style="color: rgb(230, 219, 116); ">"Swift"</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="s2" style="color: rgb(230, 219, 116); ">"Objective-C"</span><span class="p" style="color: rgb(248, 248, 242); ">]</span>
<span class="nx" style="color: rgb(166, 226, 46); ">reduce</span><span class="p" style="color: rgb(248, 248, 242); ">(</span><span class="nx" style="color: rgb(166, 226, 46); ">languages</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="s2" style="color: rgb(230, 219, 116); ">""</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="p" style="color: rgb(248, 248, 242); ">{</span> <span class="nx" style="color: rgb(166, 226, 46); ">$0</span> <span class="o" style="color: rgb(249, 38, 114); ">+</span> <span class="nx" style="color: rgb(166, 226, 46); ">$1</span> <span class="p" style="color: rgb(248, 248, 242); ">})</span> <span class="o" style="color: rgb(249, 38, 114); ">==</span> <span class="s2" style="color: rgb(230, 219, 116); ">"SwiftObjective-C"</span>
<span class="nx" style="color: rgb(166, 226, 46); ">reduce</span><span class="p" style="color: rgb(248, 248, 242); ">([</span><span class="mi" style="color: rgb(174, 129, 255); ">10</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="mi" style="color: rgb(174, 129, 255); ">20</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="mi" style="color: rgb(174, 129, 255); ">5</span><span class="p" style="color: rgb(248, 248, 242); ">],</span> <span class="mi" style="color: rgb(174, 129, 255); ">1</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="p" style="color: rgb(248, 248, 242); ">{</span> <span class="nx" style="color: rgb(166, 226, 46); ">$0</span> <span class="o" style="color: rgb(249, 38, 114); ">*</span> <span class="nx" style="color: rgb(166, 226, 46); ">$1</span> <span class="p" style="color: rgb(248, 248, 242); ">})</span> <span class="o" style="color: rgb(249, 38, 114); ">==</span> <span class="mi" style="color: rgb(174, 129, 255); ">1000</span>
- reverse(sequence):返回逆序的序列
sequence
。
<span class="nx" style="color: rgb(166, 226, 46); ">equal</span><span class="p" style="color: rgb(248, 248, 242); ">(</span><span class="nx" style="color: rgb(166, 226, 46); ">reverse</span><span class="p" style="color: rgb(248, 248, 242); ">([</span><span class="mi" style="color: rgb(174, 129, 255); ">1</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="mi" style="color: rgb(174, 129, 255); ">2</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="mi" style="color: rgb(174, 129, 255); ">3</span><span class="p" style="color: rgb(248, 248, 242); ">]),</span> <span class="p" style="color: rgb(248, 248, 242); ">[</span><span class="mi" style="color: rgb(174, 129, 255); ">3</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="mi" style="color: rgb(174, 129, 255); ">2</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="mi" style="color: rgb(174, 129, 255); ">1</span><span class="p" style="color: rgb(248, 248, 242); ">])</span>
<span class="k" style="color: rgb(102, 217, 239); ">for</span> <span class="nx" style="color: rgb(166, 226, 46); ">i</span> <span class="k" style="color: rgb(102, 217, 239); ">in</span> <span class="nx" style="color: rgb(166, 226, 46); ">reverse</span><span class="p" style="color: rgb(248, 248, 242); ">([</span><span class="mi" style="color: rgb(174, 129, 255); ">1</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="mi" style="color: rgb(174, 129, 255); ">2</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="mi" style="color: rgb(174, 129, 255); ">3</span><span class="p" style="color: rgb(248, 248, 242); ">])</span> <span class="p" style="color: rgb(248, 248, 242); ">{</span>
<span class="c1" style="color: rgb(117, 113, 94); ">// 3, 2, 1
</span> <span class="nx" style="color: rgb(166, 226, 46); ">println</span><span class="p" style="color: rgb(248, 248, 242); ">(</span><span class="nx" style="color: rgb(166, 226, 46); ">i</span><span class="p" style="color: rgb(248, 248, 242); ">)</span>
<span class="p" style="color: rgb(248, 248, 242); ">}</span>
- startsWith(sequence1, sequence2):如果序列
sequence1
中开头的元素跟序列sequence2
中的所有元素都相等,则返回true
,否则返回false
。
<span class="nx" style="color: rgb(166, 226, 46); ">startsWith</span><span class="p" style="color: rgb(248, 248, 242); ">(</span><span class="s2" style="color: rgb(230, 219, 116); ">"foobar"</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="s2" style="color: rgb(230, 219, 116); ">"foo"</span><span class="p" style="color: rgb(248, 248, 242); ">)</span> <span class="o" style="color: rgb(249, 38, 114); ">==</span> <span class="kc" style="color: rgb(102, 217, 239); ">true</span>
<span class="nx" style="color: rgb(166, 226, 46); ">startsWith</span><span class="p" style="color: rgb(248, 248, 242); ">(</span><span class="mi" style="color: rgb(174, 129, 255); ">10</span><span class="p" style="color: rgb(248, 248, 242); ">..</span><span class="mi" style="color: rgb(174, 129, 255); ">100</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="mi" style="color: rgb(174, 129, 255); ">10</span><span class="p" style="color: rgb(248, 248, 242); ">..</span><span class="mi" style="color: rgb(174, 129, 255); ">15</span><span class="p" style="color: rgb(248, 248, 242); ">)</span> <span class="o" style="color: rgb(249, 38, 114); ">==</span> <span class="kc" style="color: rgb(102, 217, 239); ">true</span>
<span class="kd" style="color: rgb(102, 217, 239); ">var</span> <span class="nx" style="color: rgb(166, 226, 46); ">languages</span> <span class="o" style="color: rgb(249, 38, 114); ">=</span> <span class="p" style="color: rgb(248, 248, 242); ">[</span><span class="s2" style="color: rgb(230, 219, 116); ">"Swift"</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="s2" style="color: rgb(230, 219, 116); ">"Objective-C"</span><span class="p" style="color: rgb(248, 248, 242); ">]</span>
<span class="nx" style="color: rgb(166, 226, 46); ">startsWith</span><span class="p" style="color: rgb(248, 248, 242); ">(</span><span class="nx" style="color: rgb(166, 226, 46); ">languages</span><span class="p" style="color: rgb(248, 248, 242); ">,</span> <span class="p" style="color: rgb(248, 248, 242); ">[</span><span class="s2" style="color: rgb(230, 219, 116); ">"Swift"</span><span class="p" style="color: rgb(248, 248, 242); ">])</span> <span class="o" style="color: rgb(249, 38, 114); ">==</span> <span class="kc" style="color: rgb(102, 217, 239); ">true</span>
上面提到的函数是我认为在Swift编程中会经常用到的函数。下面将列出完整的74个函数列表。
完整74个内置函数:
<span class="nx" style="color: rgb(166, 226, 46); ">abs</span><span class="p" style="color: rgb(248, 248, 242); ">(...)</span>
<span class="nx" style="color: rgb(166, 226, 46); ">advance</span><span class="p" style="color: rgb(248, 248, 242); ">(...)</span>
<span class="nx" style="color: rgb(166, 226, 46); ">alignof</span><span class="p" style="color: rgb(248, 248, 242); ">(...)</span>
<span class="nx" style="color: rgb(166, 226, 46); ">alignofValue</span><span class="p" style="color: rgb(248, 248, 242); ">(...)</span>
<span class="nx" style="color: rgb(166, 226, 46); ">assert</span><span class="p" style="color: rgb(248, 248, 242); ">(...)</span>
<span class="nx" style="color: rgb(166, 226, 46); ">bridgeFromObjectiveC</span><span class="p" style="color: rgb(248, 248, 242); ">(...)</span>
<span class="nx" style="color: rgb(166, 226, 46); ">bridgeFromObjectiveCUnconditional</span><span class="p" style="color: rgb(248, 248, 242); ">(...)</span>
<span class="nx" style="color: rgb(166, 226, 46); ">bridgeToObjectiveC</span><span class="p" style="color: rgb(248, 248, 242); ">(...)</span>
<span class="nx" style="color: rgb(166, 226, 46); ">bridgeToObjectiveCUnconditional</span><span class="p" style="color: rgb(248, 248, 242); ">(...)</span>
<span class="nx" style="color: rgb(166, 226, 46); ">c_malloc_size</span><span class="p" style="color: rgb(248, 248, 242); ">(...)</span>
<span class="nx" style="color: rgb(166, 226, 46); ">c_memcpy</span><span class="p" style="color: rgb(248, 248, 242); ">(...)</span>
<span class="nx" style="color: rgb(166, 226, 46); ">c_putchar</span><span class="p" style="color: rgb(248, 248, 242); ">(...)</span>
<span class="nx" style="color: rgb(166, 226, 46); ">contains</span><span class="p" style="color: rgb(248, 248, 242); ">(...)</span>
<span class="nx" style="color: rgb(166, 226, 46); ">count</span><span class="p" style="color: rgb(248, 248, 242); ">(...)</span>
<span class="nx" style="color: rgb(166, 226, 46); ">countElements</span><span class="p" style="color: rgb(248, 248, 242); ">(...)</span>
<span class="nx" style="color: rgb(166, 226, 46); ">countLeadingZeros</span><span class="p" style="color: rgb(248, 248, 242); ">(...)</span>
<span class="nx" style="color: rgb(166, 226, 46); ">debugPrint</span><span class="p" style="color: rgb(248, 248, 242); ">(...)</span>
<span class="nx" style="color: rgb(166, 226, 46); ">debugPrintln</span><span class="p" style="color: rgb(248, 248, 242); ">(...)</span>
<span class="nx" style="color: rgb(166, 226, 46); ">distance</span><span class="p" style="color: rgb(248, 248, 242); ">(...)</span>
<span class="nx" style="color: rgb(166, 226, 46); ">dropFirst</span><span class="p" style="color: rgb(248, 248, 242); ">(...)</span>
<span class="nx" style="color: rgb(166, 226, 46); ">dropLast</span><span class="p" style="color: rgb(248, 248, 242); ">(...)</span>
<span class="nx" style="color: rgb(166, 226, 46); ">dump</span><span class="p" style="color: rgb(248, 248, 242); ">(...)</span>
<span class="nx" style="color: rgb(166, 226, 46); ">encodeBitsAsWords</span><span class="p" style="color: rgb(248, 248, 242); ">(...)</span>
<span class="nx" style="color: rgb(166, 226, 46); ">enumerate</span><span class="p" style="color: rgb(248, 248, 242); ">(...)</span>
<span class="nx" style="color: rgb(166, 226, 46); ">equal</span><span class="p" style="color: rgb(248, 248, 242); ">(...)</span>
<span class="nx" style="color: rgb(166, 226, 46); ">filter</span><span class="p" style="color: rgb(248, 248, 242); ">(...)</span>
<span class="nx" style="color: rgb(166, 226, 46); ">find</span><span class="p" style="color: rgb(248, 248, 242); ">(...)</span>
<span class="nx" style="color: rgb(166, 226, 46); ">getBridgedObjectiveCType</span><span class="p" style="color: rgb(248, 248, 242); ">(...)</span>
<span class="nx" style="color: rgb(166, 226, 46); ">getVaList</span><span class="p" style="color: rgb(248, 248, 242); ">(...)</span>
<span class="nx" style="color: rgb(166, 226, 46); ">indices</span><span class="p" style="color: rgb(248, 248, 242); ">(...)</span>
<span class="nx" style="color: rgb(166, 226, 46); ">insertionSort</span><span class="p" style="color: rgb(248, 248, 242); ">(...)</span>
<span class="nx" style="color: rgb(166, 226, 46); ">isBridgedToObjectiveC</span><span class="p" style="color: rgb(248, 248, 242); ">(...)</span>
<span class="nx" style="color: rgb(166, 226, 46); ">isBridgedVerbatimToObjectiveC</span><span class="p" style="color: rgb(248, 248, 242); ">(...)</span>
<span class="nx" style="color: rgb(166, 226, 46); ">isUniquelyReferenced</span><span class="p" style="color: rgb(248, 248, 242); ">(...)</span>
<span class="nx" style="color: rgb(166, 226, 46); ">join</span><span class="p" style="color: rgb(248, 248, 242); ">(...)</span>
<span class="nx" style="color: rgb(166, 226, 46); ">lexicographicalCompare</span><span class="p" style="color: rgb(248, 248, 242); ">(...)</span>
<span class="nx" style="color: rgb(166, 226, 46); ">map</span><span class="p" style="color: rgb(248, 248, 242); ">(...)</span>
<span class="nx" style="color: rgb(166, 226, 46); ">max</span><span class="p" style="color: rgb(248, 248, 242); ">(...)</span>
<span class="nx" style="color: rgb(166, 226, 46); ">maxElement</span><span class="p" style="color: rgb(248, 248, 242); ">(...)</span>
<span class="nx" style="color: rgb(166, 226, 46); ">min</span><span class="p" style="color: rgb(248, 248, 242); ">(...)</span>
<span class="nx" style="color: rgb(166, 226, 46); ">minElement</span><span class="p" style="color: rgb(248, 248, 242); ">(...)</span>
<span class="nx" style="color: rgb(166, 226, 46); ">numericCast</span><span class="p" style="color: rgb(248, 248, 242); ">(...)</span>
<span class="nx" style="color: rgb(166, 226, 46); ">partition</span><span class="p" style="color: rgb(248, 248, 242); ">(...)</span>
<span class="nx" style="color: rgb(166, 226, 46); ">posix_read</span><span class="p" style="color: rgb(248, 248, 242); ">(...)</span>
<span class="nx" style="color: rgb(166, 226, 46); ">posix_write</span><span class="p" style="color: rgb(248, 248, 242); ">(...)</span>
<span class="nx" style="color: rgb(166, 226, 46); ">print</span><span class="p" style="color: rgb(248, 248, 242); ">(...)</span>
<span class="nx" style="color: rgb(166, 226, 46); ">println</span><span class="p" style="color: rgb(248, 248, 242); ">(...)</span>
<span class="nx" style="color: rgb(166, 226, 46); ">quickSort</span><span class="p" style="color: rgb(248, 248, 242); ">(...)</span>
<span class="nx" style="color: rgb(166, 226, 46); ">reduce</span><span class="p" style="color: rgb(248, 248, 242); ">(...)</span>
<span class="nx" style="color: rgb(166, 226, 46); ">reflect</span><span class="p" style="color: rgb(248, 248, 242); ">(...)</span>
<span class="nx" style="color: rgb(166, 226, 46); ">reinterpretCast</span><span class="p" style="color: rgb(248, 248, 242); ">(...)</span>
<span class="nx" style="color: rgb(166, 226, 46); ">reverse</span><span class="p" style="color: rgb(248, 248, 242); ">(...)</span>
<span class="nx" style="color: rgb(166, 226, 46); ">roundUpToAlignment</span><span class="p" style="color: rgb(248, 248, 242); ">(...)</span>
<span class="nx" style="color: rgb(166, 226, 46); ">sizeof</span><span class="p" style="color: rgb(248, 248, 242); ">(...)</span>
<span class="nx" style="color: rgb(166, 226, 46); ">sizeofValue</span><span class="p" style="color: rgb(248, 248, 242); ">(...)</span>
<span class="nx" style="color: rgb(166, 226, 46); ">sort</span><span class="p" style="color: rgb(248, 248, 242); ">(...)</span>
<span class="nx" style="color: rgb(166, 226, 46); ">split</span><span class="p" style="color: rgb(248, 248, 242); ">(...)</span>
<span class="nx" style="color: rgb(166, 226, 46); ">startsWith</span><span class="p" style="color: rgb(248, 248, 242); ">(...)</span>
<span class="nx" style="color: rgb(166, 226, 46); ">strideof</span><span class="p" style="color: rgb(248, 248, 242); ">(...)</span>
<span class="nx" style="color: rgb(166, 226, 46); ">strideofValue</span><span class="p" style="color: rgb(248, 248, 242); ">(...)</span>
<span class="nx" style="color: rgb(166, 226, 46); ">swap</span><span class="p" style="color: rgb(248, 248, 242); ">(...)</span>
<span class="nx" style="color: rgb(166, 226, 46); ">swift_MagicMirrorData_summaryImpl</span><span class="p" style="color: rgb(248, 248, 242); ">(...)</span>
<span class="nx" style="color: rgb(166, 226, 46); ">swift_bufferAllocate</span><span class="p" style="color: rgb(248, 248, 242); ">(...)</span>
<span class="nx" style="color: rgb(166, 226, 46); ">swift_keepAlive</span><span class="p" style="color: rgb(248, 248, 242); ">(...)</span>
<span class="nx" style="color: rgb(166, 226, 46); ">toString</span><span class="p" style="color: rgb(248, 248, 242); ">(...)</span>
<span class="nx" style="color: rgb(166, 226, 46); ">transcode</span><span class="p" style="color: rgb(248, 248, 242); ">(...)</span>
<span class="nx" style="color: rgb(166, 226, 46); ">underestimateCount</span><span class="p" style="color: rgb(248, 248, 242); ">(...)</span>
<span class="nx" style="color: rgb(166, 226, 46); ">unsafeReflect</span><span class="p" style="color: rgb(248, 248, 242); ">(...)</span>
<span class="nx" style="color: rgb(166, 226, 46); ">withExtendedLifetime</span><span class="p" style="color: rgb(248, 248, 242); ">(...)</span>
<span class="nx" style="color: rgb(166, 226, 46); ">withObjectAtPlusZero</span><span class="p" style="color: rgb(248, 248, 242); ">(...)</span>
<span class="nx" style="color: rgb(166, 226, 46); ">withUnsafePointer</span><span class="p" style="color: rgb(248, 248, 242); ">(...)</span>
<span class="nx" style="color: rgb(166, 226, 46); ">withUnsafePointerToObject</span><span class="p" style="color: rgb(248, 248, 242); ">(...)</span>
<span class="nx" style="color: rgb(166, 226, 46); ">withUnsafePointers</span><span class="p" style="color: rgb(248, 248, 242); ">(...)</span>
<span class="nx" style="color: rgb(166, 226, 46); ">withVaList</span><span class="p" style="color: rgb(248, 248, 242); ">(...)</span>