Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- // filter is declared as above.
- // apply is declared as above.
- // reduce is declared as above.
- func main() {
- in := []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
- temp := filter(in, func(n int) bool { return n%2 != 0 })
- temp = apply(temp, func(n int) int { return n * n })
- out := reduce(temp, func(a int, b int) int { return a + b })
- if !(out == (1*1)+(3*3)+(5*5)+(7*7)+(9*9)) {
- log.Fatal("Wrong value")
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement