rewrote algo for Pi calculation to use 'map' instead of 'for-yield'
This commit is contained in:
parent
4ba2296c16
commit
03914a2b0f
1 changed files with 1 additions and 2 deletions
|
|
@ -74,8 +74,7 @@ object Pi {
|
|||
// define the work
|
||||
val algorithm = (i: Int) => {
|
||||
val range = (i * nrOfElements) to ((i + 1) * nrOfElements - 1)
|
||||
val results = for (j <- range) yield (4 * math.pow(-1, j) / (2 * j + 1))
|
||||
results.sum
|
||||
range map (j => 4 * math.pow(-1, j) / (2 * j + 1)) sum
|
||||
}
|
||||
|
||||
// message handler
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue