Skip to content

Commit 087dc18

Browse files
committed
Make multiply(_:_:) function more elegant
1 parent 6c9e3a8 commit 087dc18

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Linear Regression/LinearRegression.playground/Contents.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func average(_ input: [Double]) -> Double {
3434
}
3535

3636
func multiply(_ input1: [Double], _ input2: [Double]) -> [Double] {
37-
return input1.enumerated().map({ (index, element) in return element*input2[index] })
37+
return zip(input1, input2).map { $0.0 * $0.1 }
3838
}
3939

4040
func linearRegression(_ xVariable: [Double], _ yVariable: [Double]) -> ((Double) -> Double) {

0 commit comments

Comments
 (0)