github.com/l3x/learn-fp-go@v0.0.0-20171228022418-7639825d0b71/4-purely-functional/ch09-functor-monoid/01_clock_functor/main.go (about) 1 package main 2 3 import ( 4 "log" 5 "functor" 6 ) 7 8 9 func main() { 10 11 amPmMapper := func(i int) int { 12 return (i + 12) % 24 13 } 14 15 log.Printf("initial state : %s", functor.Wrap([]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12})) 16 17 unit := func(i int) int { 18 return i 19 } 20 21 log.Printf("unit application : %s", functor.Wrap([]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}).Map(unit)) 22 23 log.Printf("1st application : %s", functor.Wrap([]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}).Map(amPmMapper)) 24 25 log.Printf("chain applications: %s", functor.Wrap([]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}).Map(amPmMapper).Map(amPmMapper)) 26 27 log.Printf("chain applications: %s", functor.Wrap([]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}).Map(amPmMapper)) 28 } 29