Skip to content

Commit f7b3996

Browse files
committed
Updated Knuth-Morris-Pratt to Swift 4.2
1 parent d4fd216 commit f7b3996

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

Knuth-Morris-Pratt/KnuthMorrisPratt.playground/Contents.swift

+2-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
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, Swift4!")
6-
#endif
7-
83
func ZetaAlgorithm(ptnr: String) -> [Int]? {
94

10-
let pattern = Array(ptnr.characters)
5+
let pattern = Array(ptnr)
116
let patternLength: Int = pattern.count
127

138
guard patternLength > 0 else {
@@ -65,7 +60,7 @@ extension String {
6560

6661
func indexesOf(ptnr: String) -> [Int]? {
6762

68-
let text = Array(self.characters)
63+
let text = Array(self)
6964
let pattern = Array(ptnr.characters)
7065

7166
let textLength: Int = text.count

0 commit comments

Comments
 (0)