Last active
December 15, 2018 08:15
-
-
Save ivancorrales/fd15ef2ff40ef069db7a4a309a93b441 to your computer and use it in GitHub Desktop.
stream.Add / stream.Drop / stream.DeleteAt / stream.Pop
This file contains hidden or 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
package main | |
import ( | |
"fmt" | |
"github.com/wesovilabs/koazee" | |
) | |
var numbers = []int{1, 5, 4, 3, 2, 7, 1, 8, 2, 3} | |
func main() { | |
fmt.Print("input: ") | |
fmt.Println(numbers) | |
stream := koazee.StreamOf(numbers) | |
fmt.Print("stream.Add(10): ") | |
fmt.Println(stream.Add(10).Do().Out().Val()) | |
fmt.Print("stream.Drop(5): ") | |
fmt.Println(stream.Drop(5).Do().Out().Val()) | |
fmt.Print("stream.DeleteAt(4): ") | |
fmt.Println(stream.DeleteAt(4).Do().Out().Val()) | |
fmt.Print("stream.Pop(): ") | |
val, newStream := stream.Pop() | |
fmt.Printf("%d ... ", val.Int()) | |
fmt.Println(newStream.Out().Val()) | |
} | |
/** | |
go run main.go | |
input: [1 5 4 3 2 7 1 8 2 3] | |
stream.Add(10): [1 5 4 3 2 7 1 8 2 3 10] | |
stream.Drop(5): [1 4 3 2 7 1 8 2 3] | |
stream.DeleteAt(4): [1 5 4 3 7 1 8 2 3] | |
stream.Pop(): 1 ... [5 4 3 2 7 1 8 2 3] | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment