Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c2522c0

Browse files
committed
tiny changes to comments
1 parent 078d467 commit c2522c0

File tree

2 files changed

+4
-8
lines changed
  • Classic Computer Science Problems in Swift.playground/Pages

2 files changed

+4
-8
lines changed

‎Classic Computer Science Problems in Swift.playground/Pages/Chapter 1.xcplaygroundpage/Contents.swift

Lines changed: 3 additions & 3 deletions
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) }

‎Classic Computer Science Problems in Swift.playground/Pages/Chapter 2.xcplaygroundpage/Contents.swift

Lines changed: 1 addition & 5 deletions
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)

AltStyle によって変換されたページ (->オリジナル) /