Skip to content

Commit 055e0ea

Browse files
authored
Fix broken links/incorrect variance calculation (apple#422)
1 parent 554e765 commit 055e0ea

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

Examples/math/Math.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ extension Math.Statistics {
176176
let squaredErrors = values
177177
.map { $0 - mean }
178178
.map { $0 * $0 }
179-
let variance = squaredErrors.reduce(0, +)
179+
let variance = squaredErrors.reduce(0, +) / Double(values.count)
180180
let result = variance.squareRoot()
181181
print(result)
182182
}

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,10 @@ For guides, articles, and API documentation see the
8181

8282
This repository includes a few examples of using the library:
8383

84-
- [`repeat`](Examples/repeat/main.swift) is the example shown above.
84+
- [`repeat`](Examples/repeat/Repeat.swift) is the example shown above.
8585
- [`roll`](Examples/roll/main.swift) is a simple utility implemented as a straight-line script.
86-
- [`math`](Examples/math/main.swift) is an annotated example of using nested commands and subcommands.
86+
- [`math`](Examples/math/Math.swift) is an annotated example of using nested commands and subcommands.
87+
- [`count-lines`](Examples/count-lines/CountLines.swift) uses `async`/`await` code in its implementation.
8788

8889
You can also see examples of `ArgumentParser` adoption among Swift project tools:
8990

Sources/ArgumentParser/Documentation.docc/Articles/CommandsAndSubcommands.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ extension Math.Statistics {
164164
let squaredErrors = values
165165
.map { $0 - mean }
166166
.map { $0 * $0 }
167-
let variance = squaredErrors.reduce(0, +)
167+
let variance = squaredErrors.reduce(0, +) / Double(values.count)
168168
let result = variance.squareRoot()
169169
print(result)
170170
}

0 commit comments

Comments
 (0)