Skip to content

Commit

Permalink
Example #20: Reduce method
Browse files Browse the repository at this point in the history
  • Loading branch information
tisnik committed Jul 13, 2020
1 parent 5992500 commit 1f2fc4f
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions lesson7/lazy_streams/20_reduce.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package main

import (
"fmt"
"github.com/wesovilabs/koazee"
)

func add(x, y int) int {
return x + y
}

func main() {
values1 := []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
fmt.Printf("input #1: %v\n", values1)

sum := koazee.StreamOf(values1).Reduce(add)
fmt.Printf("sum: %d\n", sum.Val())
}

0 comments on commit 1f2fc4f

Please sign in to comment.