File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,9 @@ func calculatePi(nTerms: UInt) -> Double {
167167
var operation: Double = -1
168168
var pi: Double = 0
169169
for _ in 0..<nTerms {
170-
pi = pi + operation * (numerator / denominator)
170+
pi += operation * (numerator / denominator)
171171
denominator += 2
172-
operation = operation * -1
172+
operation *= -1
173173
}
174174
return abs(pi)
175175
}
@@ -179,7 +179,7 @@ calculatePi(nTerms: 1000)
179179

180180
/// The Towers of Hanoi
181181

182-
/// Implements a stack - helper class that uses an array internally.
182+
/// Implements a stack - LIFO helper class that uses an array internally.
183183
public class Stack<T>: CustomStringConvertible {
184184
private var container: [T] = [T]()
185185
public func push(_ thing: T) { container.append(thing) }
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ for _ in 0..<1000 {
102102
}
103103
let elapsedTime2 = CFAbsoluteTimeGetCurrent() - startTime2*/
104104

105-
//generic versions for dictionary
105+
/// Generic Versions
106106

107107
func linearContains<T: Equatable>(_ array: [T], item: T) -> Bool {
108108
for element in array where item == element {
@@ -111,10 +111,6 @@ func linearContains<T: Equatable>(_ array: [T], item: T) -> Bool {
111111
return false
112112
}
113113

114-
//linearContains(gene, item: ac1)
115-
116-
gene.sort(by: <)
117-
118114
func binaryContains<T: Comparable>(_ array: [T], item: T) -> Bool {
119115
var low = 0
120116
var high = array.count - 1

0 commit comments

Comments
 (0)