File tree Expand file tree Collapse file tree 4 files changed +6
-14
lines changed Expand file tree Collapse file tree 4 files changed +6
-14
lines changed Original file line number Diff line number Diff line change @@ -28,8 +28,7 @@ This a simple description of the idea that is behind this algorithm. There are a
2828Here is the code of the function that computes the Z-array:
2929``` swift
3030func ZetaAlgorithm (ptrn : String ) -> [Int ]? {
31-
32- let pattern = Array (ptrn.characters )
31+ let pattern = Array (ptrn)
3332 let patternLength: Int = pattern.count
3433
3534 guard patternLength > 0 else {
@@ -131,7 +130,7 @@ The Z-Algorithm discussed above leads to the simplest linear-time string matchin
131130extension String {
132131
133132 func indexesOf (pattern : String ) -> [Int ]? {
134- let patternLength: Int = pattern.characters . count
133+ let patternLength: Int = pattern.count
135134 /* Let's calculate the Z-Algorithm on the concatenation of pattern and text */
136135 let zeta = ZetaAlgorithm (ptrn : pattern + " 💲" + self )
137136
Original file line number Diff line number Diff line change 99import Foundation
1010
1111func ZetaAlgorithm( ptrn: String ) -> [ Int ] ? {
12-
13- let pattern = Array ( ptrn. characters)
12+ let pattern = Array ( ptrn)
1413 let patternLength = pattern. count
1514
1615 guard patternLength > 0 else {
Original file line number Diff line number Diff line change 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-
83func ZetaAlgorithm( ptrn: String ) -> [ Int ] ? {
9-
10- let pattern = Array ( ptrn. characters)
4+ let pattern = Array ( ptrn)
115 let patternLength = pattern. count
126
137 guard patternLength > 0 else {
@@ -65,7 +59,7 @@ func ZetaAlgorithm(ptrn: String) -> [Int]? {
6559extension String {
6660
6761 func indexesOf( pattern: String ) -> [ Int ] ? {
68- let patternLength = pattern. characters . count
62+ let patternLength = pattern. count
6963 let zeta = ZetaAlgorithm ( ptrn: pattern + " 💲 " + self )
7064
7165 guard zeta != nil else {
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ import Foundation
1111extension String {
1212
1313 func indexesOf( pattern: String ) -> [ Int ] ? {
14- let patternLength = pattern. characters . count
14+ let patternLength = pattern. count
1515 let zeta = ZetaAlgorithm ( ptrn: pattern + " 💲 " + self )
1616
1717 guard zeta != nil else {
You can’t perform that action at this time.
0 commit comments