Skip to content

Commit e4ae21d

Browse files
authored
Merge pull request #541 from bobdel/Swift4-updates
10 new Swift 4 updates
2 parents 9971ae6 + 2f339ad commit e4ae21d

File tree

13 files changed

+55
-10
lines changed

13 files changed

+55
-10
lines changed

Linear Search/LinearSearch.playground/Contents.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//: Playground - noun: a place where people can play
22

3-
// last checked with Xcode 4.0b4
3+
// last checked with Xcode 9.0b4
44
#if swift(>=4.0)
55
print("Hello, Swift 4!")
66
#endif

Minimum Edit Distance/MinimumEditDistance.playground/Contents.swift

100755100644
Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
// Minimum Edit Distance
2+
3+
// last checked with Xcode 9.0b4
4+
#if swift(>=4.0)
5+
print("Hello, Swift 4!")
6+
#endif
7+
18
extension String {
29

310
public func minimumEditDistance(other: String) -> Int {
@@ -25,7 +32,7 @@ extension String {
2532
} else {
2633
// minimum of the cost of insertion, deletion, or substitution
2734
// added to the already computed costs in the corresponding cells
28-
matrix[i + 1][j + 1] = min(matrix[i][j] + 1, matrix[i + 1][j] + 1, matrix[i][j + 1] + 1)
35+
matrix[i + 1][j + 1] = Swift.min(matrix[i][j] + 1, matrix[i + 1][j] + 1, matrix[i][j + 1] + 1)
2936
}
3037
}
3138
}

Minimum Edit Distance/MinimumEditDistance.playground/contents.xcplayground

100755100644
File mode changed.

Minimum Edit Distance/README.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ for (i, selfChar) in self.characters.enumerated() {
4545
} else {
4646
// minimum of the cost of insertion, deletion, or substitution
4747
// added to the already computed costs in the corresponding cells
48-
matrix[i + 1][j + 1] = min(matrix[i][j] + 1, matrix[i + 1][j] + 1, matrix[i][j + 1] + 1)
48+
matrix[i + 1][j + 1] = Swift.min(matrix[i][j] + 1, matrix[i + 1][j] + 1, matrix[i][j + 1] + 1)
4949
}
5050
}
5151
}

Monty Hall Problem/MontyHall.playground/Contents.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
//: Playground - noun: a place where people can play
22

3+
// last checked with Xcode 9.0b4
4+
#if swift(>=4.0)
5+
print("Hello, Swift 4!")
6+
#endif
7+
38
import Foundation
49

510
func random(_ n: Int) -> Int {
@@ -43,7 +48,7 @@ func playRound() {
4348
}
4449

4550
// Run the simulation a large number of times.
46-
for i in 1...5000 {
51+
for _ in 1...5000 {
4752
playRound()
4853
}
4954

Naive Bayes Classifier/NaiveBayes.playground/Contents.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
import Foundation
22

3+
// last checked with Xcode 9.0b4
4+
#if swift(>=4.0)
5+
print("Hello, Swift 4!")
6+
#endif
7+
38
/*:
49
## Naive Bayes Classifier
510

Rabin-Karp/Rabin-Karp.playground/Contents.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
//: Taking our rabin-karp algorithm for a walk
22

3+
// last checked with Xcode 9.0b4
4+
#if swift(>=4.0)
5+
print("Hello, Swift 4!")
6+
#endif
7+
38
import UIKit
49

510
struct Constants {

Radix Tree/RadixTree.playground/Contents.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
// Radix Tree
2+
3+
// last checked with Xcode 9.0b4
4+
#if swift(>=4.0)
5+
print("Hello, Swift 4!")
6+
#endif
7+
18
var radix = RadixTree()
29
var radixWiki = RadixTree()
310

Ring Buffer/RingBuffer.playground/Contents.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
//: Playground - noun: a place where people can play
22

3+
// last checked with Xcode 9.0b4
4+
#if swift(>=4.0)
5+
print("Hello, Swift 4!")
6+
#endif
7+
38
public struct RingBuffer<T> {
49
fileprivate var array: [T?]
510
fileprivate var readIndex = 0

Run-Length Encoding/RLE.playground/Contents.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
//: Playground - noun: a place where people can play
22

3+
// last checked with Xcode 9.0b4
4+
#if swift(>=4.0)
5+
print("Hello, Swift 4!")
6+
#endif
7+
38
import Foundation
49

510
let originalString = "aaaaabbbcdeeeeeeef"

Run-Length Encoding/RLE.playground/timeline.xctimeline

Lines changed: 0 additions & 6 deletions
This file was deleted.

Selection Sampling/SelectionSampling.playground/Contents.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
//: Playground - noun: a place where people can play
22

3+
// last checked with Xcode 9.0b4
4+
#if swift(>=4.0)
5+
print("Hello, Swift 4!")
6+
#endif
7+
38
import Foundation
49

510
/* Returns a random integer in the range min...max, inclusive. */

Set Cover (Unweighted)/SetCover.playground/Contents.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
// SetCover
2+
3+
// last checked with Xcode 9.0b4
4+
#if swift(>=4.0)
5+
print("Hello, Swift 4!")
6+
#endif
7+
18
let universe1 = Set(1...7)
29
let array1 = randomArrayOfSets(covering: universe1)
310
let cover1 = universe1.cover(within: array1)

0 commit comments

Comments
 (0)