Skip to content

Commit

Permalink
Example #19: Improper combination of more stream manipulators
Browse files Browse the repository at this point in the history
  • Loading branch information
tisnik committed Jul 13, 2020
1 parent c975f68 commit 5992500
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions lesson7/lazy_streams/19_combinations_error.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package main

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

func printInt(x int) {
fmt.Printf("%d\n", x)
}

func doubleValue(x int) int {
return x * 2
}

func negate(x int) int {
return -x
}

func evenValue(x int) bool {
return x%2 == 0
}

func divisibleBy3(x int) bool {
return x%3 == 0
}

func main() {
values1 := []int{1, 2, 3}
fmt.Printf("input #1: %v\n", values1)

stream1 := koazee.StreamOf(values1).
Filter(evenValue).
Filter(divisibleBy3).
Map(negate).
Map(doubleValue)
stream1.ForEach(printInt).Do()
}

0 comments on commit 5992500

Please sign in to comment.