★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
➤微信公衆號:山青詠芝(shanqingyongzhi)
➤博客園地址:山青詠芝(https://www.cnblogs.com/strengthen/)
➤GitHub地址:https://github.com/strengthen/LeetCode
➤原文地址:http://www.javashuo.com/article/p-bgmqvmcv-kx.html
➤若是連接不是山青詠芝的博客園地址,則多是爬取做者的文章。
➤原文已修改更新!強烈建議點擊原文地址閱讀!支持做者!支持原創!
★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★html
目錄:[Swift]通天遁地Swiftios
本文將演示擴展集合類型實現對集合中數據的多種運算。git
首先確保在項目中已經安裝了所需的第三方庫。github
點擊【Podfile】,查看安裝配置文件。swift
根據配置文件中的相關配置,安裝第三方庫。數組
1 platform :ios, '12.0' 2 use_frameworks! 3 4 target 'DemoApp' do 5 source 'https://github.com/CocoaPods/Specs.git' 6 pod "Arithmosophi" 7 end
而後點擊打開【DemoApp.xcworkspace】項目文件。微信
在項目導航區,打開視圖控制器的代碼文件【ViewController.swift】ide
如今開始編寫代碼,快速檢測設備的各類屬性。post
1 import UIKit 2 3 class ViewController: UIViewController { 4 5 override func viewDidLoad() { 6 super.viewDidLoad() 7 // Do any additional setup after loading the view, typically from a nib. 8 9 //數組求和 10 print("sum:\([1, 2, 3, 4].sum)") 11 //數組求積 12 print("product:\([1, 2, 3, 4].product)") 13 //字符串組成的數組,進行求和運算, 14 //返回拼合而成的字符串 15 print("sum:\(["a","b","c","d"].sum)") 16 //字符串數組組成的數組,進行求和運算, 17 //返回拼合而成的字符串數組 18 print("sum:\([["a","b"],["c"],["d"]].sum)") 19 //求平均值 20 print("average:\([1, 2, 3, 4].average)") 21 22 print("---------------------") 23 //中間值 24 print("median:\([1, 11, 19, 4, -7].median)") 25 //有兩個中間值時,取較小的一個 26 print("medianLow:\([1.0, 11, 19.5, 4, 12, -7].medianLow)") 27 //有兩個中間值時,取較大的一個 28 print("medianHigh:\([1, 11, 19, 4, 12, -7].medianHigh)") 29 //取樣本方差 30 print("varianceSample:\([1.0, 11, 19.5, 4, 12, -7].varianceSample)") 31 //取整體方差 32 print("variancePopulation:\([1.0, 11, 19.5, 4, 12, -7].variancePopulation)") 33 //標準樣本誤差 34 print("standardDeviationSample:\([1.0, 11, 19.5, 4, 12, -7].standardDeviationSample)") 35 //標準整體誤差 36 print("standardDeviationPopulation:\([1.0, 11, 19.5, 4, 12, -7].standardDeviationPopulation)") 37 38 print("---------------------") 39 //傾斜度 40 print("skewness:\([1.0, 11, 19.5, 4, 12, -7].skewness)") 41 //峯度 42 print("kurtosis:\([1.0, 11, 19.5, 4, 12, -7].kurtosis)") 43 //樣本協方差 44 print("covarianceSample:\([1, 2, 3.5, 3.7, 8, 12].covarianceSample([0.5, 1, 2.1, 3.4, 3.4, 4]))") 45 //整體協方差 46 print("covariancePopulation:\([1, 2, 3.5, 3.7, 8, 12].covariancePopulation([0.5, 1, 2.1, 3.4, 3.4, 4]))") 47 //皮爾遜積差相關係數 48 print("pearson:\([1, 2, 3.5, 3.7, 8, 12].pearson([0.5, 1, 2.1, 3.4, 3.4, 4]))") 49 } 50 51 override func didReceiveMemoryWarning() { 52 super.didReceiveMemoryWarning() 53 // Dispose of any resources that can be recreated. 54 } 55 }