-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Example #19: Improper combination of more stream manipulators
- Loading branch information
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
} |