Skip to content

Commit 58a7f1c

Browse files
committed
Update multiply(_:_:) in README.md
1 parent 95efaec commit 58a7f1c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Linear Regression/README.markdown

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ We are using the ```reduce``` Swift function to sum up all the elements of the a
113113
We also need to be able to multiply each element in an array by the corresponding element in another array, to create a new array. Here is a function which will do this:
114114

115115
```swift
116-
func multiply(input1: [Double], _ input2: [Double]) -> [Double] {
117-
return input1.enumerate().map({ (index, element) in return element*input2[index] })
116+
func multiply(_ a: [Double], _ b: [Double]) -> [Double] {
117+
return zip(a,b).map { $0.0 * $0.1 }
118118
}
119119
```
120120

0 commit comments

Comments
 (0)