Last active
October 8, 2018 17:07
-
-
Save azihsoyn/0706b65ad67b02321cd03896085c915f to your computer and use it in GitHub Desktop.
collection by contract
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
type List(type T) []T | |
func (l *List(T)) Filter(func(T) bool) *List(T) | |
func (l *List(T)) Map(func(T) T) *List(T) | |
func main(){ | |
var l List{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10} | |
l.Filter(func(i int) bool { | |
return i % 2 == 0 | |
}).Map(func(i int) string{ | |
return fmt.Sprintf("No. %d", i) | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment