SlideShare a Scribd company logo
1 of 90
Going Loopy
              adventures in iteration with Google Go


                         Eleanor McHugh




Going Loopy                     1            http://slides.games-with-brains.net/
the conditional loop



Going Loopy            2     http://slides.games-with-brains.net/
package main
        import "fmt"

        func main() {
          s := []int{0, 2, 4, 6, 8}
          for i := 0; i < len(s); i++ {
            fmt.Printf("%v: %vn", i, s[i])
          }
        }




Going Loopy                           3       http://slides.games-with-brains.net/
package main
        import "fmt"

        func main() {
          s := []int{0, 2, 4, 6, 8}
          for i := 0; i < len(s); i++ {
            fmt.Printf("%v: %vn", i, s[i])
          }
        }



        0:    0
        1:    2
        2:    4
        3:    6
        4:    8




Going Loopy                           4       http://slides.games-with-brains.net/
package main
        import "fmt"

        func main() {
          s := []int{0, 2, 4, 6, 8}
          for i := 0; i < len(s); i++ {
            fmt.Printf("%v: %vn", i, s[i])
          }
        }




Going Loopy                           5       http://slides.games-with-brains.net/
package main
        import "fmt"

        func main() {
          s := []int{0, 2, 4, 6, 8}
          for i := 0; i < len(s); i++ {
            fmt.Printf("%v: %vn", i, s[i])
          }
        }




Going Loopy                           6       http://slides.games-with-brains.net/
package main
        import "fmt"

        func main() {
          s := []int{0, 2, 4, 6, 8}
          for i := 0; i < len(s); i++ {
            fmt.Printf("%v: %vn", i, s[i])
          }
        }




Going Loopy                           7       http://slides.games-with-brains.net/
package main
        import . "fmt"

        func main() {
          s := []int{0, 2, 4, 6, 8}
          for i := 0; i < len(s); i++ {
            Printf("%v: %vn", i, s[i])
          }
        }




Going Loopy                           8   http://slides.games-with-brains.net/
package main
        import . "fmt"

        func main() {
          s := []int{0, 2, 4, 6, 8}
          for i := 0; i < len(s); i++ {
            Printf("%v: %vn", i, s[i])
          }
        }




Going Loopy                           9   http://slides.games-with-brains.net/
package main
        import . "fmt"

        func main() {
          s := []int{0, 2, 4, 6, 8}
          for i := 0; i < len(s); i++ {
            Printf("%v: %vn", i, s[i])
          }
        }




Going Loopy                          10   http://slides.games-with-brains.net/
package main
        import . "fmt"

        func main() {
          s := []int{0, 2, 4, 6, 8}
          for i := 0; i < len(s); i++ {
            Printf("%v: %vn", i, s[i])
          }
        }




Going Loopy                          11   http://slides.games-with-brains.net/
package main
        import . "fmt"

        func main() {
          s := []int{0, 2, 4, 6, 8}
          for i := 0; i < len(s); i++ {
            Printf("%v: %vn", i, s[i])
          }
        }




Going Loopy                          12   http://slides.games-with-brains.net/
package main
        import . "fmt"

        func main() {
          s := []int{0, 2, 4, 6, 8}
          for i := 0; i < len(s); i++ {
            Printf("%v: %vn", i, s[i])
          }
        }




Going Loopy                          13   http://slides.games-with-brains.net/
package main
        import . "fmt"

        func main() {
          s := []int{0, 2, 4, 6, 8}
          for i := 0; i < len(s); i++ {
            Printf("%v: %vn", i, s[i])
          }
        }




Going Loopy                          14   http://slides.games-with-brains.net/
package main
        import . "fmt"

        func main() {
          s := []int{0, 2, 4, 6, 8}
          for i := 0; i < len(s); i++ {
            Printf("%v: %vn", i, s[i])
          }
        }




Going Loopy                          15   http://slides.games-with-brains.net/
package main
        import . "fmt"

        func main() {
          s := []int{0, 2, 4, 6, 8}
          for i := 0; i < len(s); i++ {
            Printf("%v: %vn", i, s[i])
          }
        }




Going Loopy                          16   http://slides.games-with-brains.net/
package main
        import . "fmt"

        func main() {
          s := []int{0, 2, 4, 6, 8}
          for i := 0; i < len(s); i++ {
            Printf("%v: %vn", i, s[i])
          }
        }




Going Loopy                          17   http://slides.games-with-brains.net/
package main
        import . "fmt"

        func main() {
          s := []int{0, 2, 4, 6, 8}
          for i := 0; i < len(s); i++ {
            Printf("%v: %vn", i, s[i])
          }
        }




Going Loopy                          18   http://slides.games-with-brains.net/
package main
        import . "fmt"

        func main() {
          s := []int{0, 2, 4, 6, 8}
          for i := 0; i < len(s); i++ {
            Printf("%v: %vn", i, s[i])
          }
        }




Going Loopy                          19   http://slides.games-with-brains.net/
package main
        import . "fmt"

        func main() {
          s := []int{0, 2, 4, 6, 8}
          for i := 0; i < len(s); i++ {
            Printf("%v: %vn", i, s[i])
          }
        }




Going Loopy                          20   http://slides.games-with-brains.net/
package main
        import . "fmt"

        func main() {
          s := []int{0, 2, 4, 6, 8}
          for i := 0; i < len(s); i++ {
            Printf("%v: %vn", i, s[i])
          }
        }




Going Loopy                          21   http://slides.games-with-brains.net/
package main
        import . "fmt"

        func main() {
          s := []int{0, 2, 4, 6, 8}
          for i := 0; i < len(s); i++ {
            Printf("%v: %vn", i, s[i])
          }
        }




Going Loopy                          22   http://slides.games-with-brains.net/
the infinite loop



Going Loopy          23    http://slides.games-with-brains.net/
package main
        import . "fmt"

        func main() {
          defer func() {
            recover()
          }()
          s := []int{0, 2, 4, 6, 8}
          for i := 0; ; i++ {
            Printf("%v: %vn", i, s[i])
          }
        }




Going Loopy                           24   http://slides.games-with-brains.net/
package main
        import . "fmt"

        func main() {
          defer func() {
            recover()
          }()
          s := []int{0, 2, 4, 6, 8}
          for i := 0; ; i++ {
            Printf("%v: %vn", i, s[i])
          }
        }




Going Loopy                           25   http://slides.games-with-brains.net/
package main
        import . "fmt"

        func main() {
          defer func() {
            recover()
          }()
          s := []int{0, 2, 4, 6, 8}
          for i := 0; ; i++ {
            Printf("%v: %vn", i, s[i])
          }
        }




Going Loopy                           26   http://slides.games-with-brains.net/
package main
        import . "fmt"

        func main() {
          defer func() {
            recover()
          }()
          s := []int{0, 2, 4, 6, 8}
          for i := 0; ; i++ {
            Printf("%v: %vn", i, s[i])
          }
        }




Going Loopy                           27   http://slides.games-with-brains.net/
package main
        import . "fmt"

        func main() {
          defer func() {
            recover()
          }()
          s := []int{0, 2, 4, 6, 8}
          for i := 0; ; i++ {
            Printf("%v: %vn", i, s[i])
          }
        }




Going Loopy                           28   http://slides.games-with-brains.net/
the range



Going Loopy       29      http://slides.games-with-brains.net/
package main
        import . "fmt"

        func main() {
          s := []int{0, 2, 4, 6, 8}
          for i, v := range s {
            Printf("%v: %vn", i, v)
          }
        }




Going Loopy                            30   http://slides.games-with-brains.net/
package main
        import . "fmt"

        func main() {
          s := []int{0, 2, 4, 6, 8}
          for i, v := range s {
            Printf("%v: %vn", i, v)
          }
        }




Going Loopy                            31   http://slides.games-with-brains.net/
package main
        import . "fmt"

        func main() {
          s := []int{0, 2, 4, 6, 8}
          for i, v := range s {
            Printf("%v: %vn", i, v)
          }
        }




Going Loopy                            32   http://slides.games-with-brains.net/
package main
        import . "fmt"

        func main() {
          s := []int{0, 2, 4, 6, 8}
          for i, v := range s {
            Printf("%v: %vn", i, v)
          }
        }




Going Loopy                            33   http://slides.games-with-brains.net/
package main
        import . "fmt"

        func main() {
          s := []int{0, 2, 4, 6, 8}
          for i, v := range s {
            Printf("%v: %vn", i, v)
          }
        }




Going Loopy                            34   http://slides.games-with-brains.net/
package main
        import . "fmt"

        func main() {
          s := []int{0, 2, 4, 6, 8}
          for i, v := range s {
            Printf("%v: %vn", i, v)
          }
        }




Going Loopy                            35   http://slides.games-with-brains.net/
a functional interlude



Going Loopy        36    http://slides.games-with-brains.net/
package main
        import . "fmt"

        func main() {
          print_slice([]int{0, 2, 4, 6, 8})
        }

        func print_slice(s []int) {
          for i, v := range s {
            Printf("%v: %vn", i, v)
          }
        }




Going Loopy                            37     http://slides.games-with-brains.net/
package main
        import . "fmt"

        func main() {
          print_slice([]int{0, 2, 4, 6, 8})
        }

        func print_slice(s []int) {
          for i, v := range s {
            Printf("%v: %vn", i, v)
          }
        }




Going Loopy                            38     http://slides.games-with-brains.net/
package main
        import . "fmt"

        func main() {
          print_slice([]int{0, 2, 4, 6, 8})
        }

        func print_slice(s []int) {
          for i, v := range s {
            Printf("%v: %vn", i, v)
          }
        }




Going Loopy                            39     http://slides.games-with-brains.net/
package main
        import . "fmt"

        func main() {
          print_slice([]int{0, 2, 4, 6, 8})
        }

        func print_slice(s []int) {
          for i, v := range s {
            Printf("%v: %vn", i, v)
          }
        }




Going Loopy                            40     http://slides.games-with-brains.net/
package main
        import . "fmt"

        func main() {
          print_slice(0, 2, 4, 6, 8)
        }

        func print_slice(s ...int) {
          for i, v := range s {
            Printf("%v: %vn", i, v)
          }
        }




Going Loopy                            41   http://slides.games-with-brains.net/
package main
        import . "fmt"

        func main() {
          print_slice(0, 2, 4, 6, 8)
        }

        func print_slice(s ...int) {
          for i, v := range s {
            Printf("%v: %vn", i, v)
          }
        }




Going Loopy                            42   http://slides.games-with-brains.net/
package main
        import . "fmt"

        func main() {
          print_slice(0, 2, 4, 6, 8)
        }

        func print_slice(s ...int) {
          for i, v := range s {
            Printf("%v: %vn", i, v)
          }
        }




Going Loopy                            43   http://slides.games-with-brains.net/
asserting type



Going Loopy         44    http://slides.games-with-brains.net/
package main
        import . "fmt"

        func main() {
          print_slice([]int{0, 2, 4, 6, 8})
        }

        func print_slice(s interface{}) {
          for i, v := range s.([]int) {
            Printf("%v: %vn", i, v)
          }
        }




Going Loopy                          45       http://slides.games-with-brains.net/
package main
        import . "fmt"

        func main() {
          print_slice([]int{0, 2, 4, 6, 8})
        }

        func print_slice(s interface{}) {
          for i, v := range s.([]int) {
            Printf("%v: %vn", i, v)
          }
        }




Going Loopy                          46       http://slides.games-with-brains.net/
package main
        import . "fmt"

        func main() {
          print_slice([]int{0, 2, 4, 6, 8})
        }

        func print_slice(s interface{}) {
          for i, v := range s.([]int) {
            Printf("%v: %vn", i, v)
          }
        }




Going Loopy                          47       http://slides.games-with-brains.net/
package main
        import . "fmt"

        func main() {
          print_slice([]int{0, 2, 4, 6, 8})
        }

        func print_slice(s interface{}) {
          if s, ok := s.([]int); ok {
            for i, v := range s {
              Printf("%v: %vn", i, v)
            }
          }
        }




Going Loopy                          48       http://slides.games-with-brains.net/
package main
        import . "fmt"

        func main() {
          print_slice([]int{0, 2, 4, 6, 8})
        }

        func print_slice(s interface{}) {
          if s, ok := s.([]int); ok {
            for i, v := range s {
              Printf("%v: %vn", i, v)
            }
          }
        }




Going Loopy                          49       http://slides.games-with-brains.net/
package main
        import . "fmt"

        func main() {
          print_slice([]int{0, 2, 4, 6, 8})
        }

        func print_slice(s interface{}) {
          if s, ok := s.([]int); ok {
            for i, v := range s {
              Printf("%v: %vn", i, v)
            }
          }
        }




Going Loopy                          50       http://slides.games-with-brains.net/
package main
        import . "fmt"

        func main() {
          print_slice([]int{0, 2, 4, 6, 8})
        }

        func print_slice(s interface{}) {
          if s, ok := s.([]int); ok {
            for i, v := range s {
              Printf("%v: %vn", i, v)
            }
          }
        }




Going Loopy                          51       http://slides.games-with-brains.net/
package main
        import . "fmt"

        func main() {
          print_slice([]int{0, 2, 4, 6, 8})
        }

        func print_slice(s interface{}) {
          if s, ok := s.([]int); ok {
            for i, v := range s {
              Printf("%v: %vn", i, v)
            }
          }
        }




Going Loopy                          52       http://slides.games-with-brains.net/
package main
        import . "fmt"

        func main() {
          print_slice([]int{0, 2, 4, 6, 8})
        }

        func print_slice(s interface{}) {
          if s, ok := s.([]int); ok {
            for i, v := range s {
              Printf("%v: %vn", i, v)
            }
          }
        }




Going Loopy                          53       http://slides.games-with-brains.net/
package main
        import . "fmt"

        func main() {
          print_slice([]int{0, 2, 4, 6, 8})
        }

        func print_slice(s interface{}) {
          switch s := s.(type) {
          case []int:
            for i, v := range s {
              Printf("%v: %vn", i, v)
            }
          }
        }




Going Loopy                          54       http://slides.games-with-brains.net/
package main
        import . "fmt"

        func main() {
          print_slice([]int{0, 2, 4, 6, 8})
        }

        func print_slice(s interface{}) {
          switch s := s.(type) {
          case []int:
            for i, v := range s {
              Printf("%v: %vn", i, v)
            }
          }
        }




Going Loopy                          55       http://slides.games-with-brains.net/
package main
        import . "fmt"

        func main() {
          print_slice([]int{0, 2, 4, 6, 8})
        }

        func print_slice(s interface{}) {
          switch s := s.(type) {
          case []int:
            for i, v := range s {
              Printf("%v: %vn", i, v)
            }
          }
        }




Going Loopy                          56       http://slides.games-with-brains.net/
package main
        import . "fmt"

        func main() {
          print_slice([]int{0, 2, 4, 6, 8})
        }

        func print_slice(s interface{}) {
          switch s := s.(type) {
          case []int:
            for i, v := range s {
              Printf("%v: %vn", i, v)
            }
          }
        }




Going Loopy                          57       http://slides.games-with-brains.net/
package main
        import . "fmt"

        func main() {
          print_slice([]int{0, 2, 4, 6, 8})
        }

        func print_slice(s interface{}) {
          switch s := s.(type) {
          case []int:
            for i, v := range s {
              Printf("%v: %vn", i, v)
            }
          }
        }




Going Loopy                          58       http://slides.games-with-brains.net/
package main
        import . "fmt"

        func main() {
          print_slice([]int{0, 2, 4, 6, 8})
        }

        func print_slice(s interface{}) {
          switch s := s.(type) {
          case []int:
            for i, v := range s {
              Printf("%v: %vn", i, v)
            }
          }
        }




Going Loopy                          59       http://slides.games-with-brains.net/
closures



Going Loopy      60      http://slides.games-with-brains.net/
package main
        import . "fmt"

        func main() {
          s := []int{0, 2, 4, 6, 8}
          print_slice(func(i int) int { return s[i] })
        }

        func print_slice(s interface{}) {
          switch s := s.(type) {
          case func(int) int:
            for i := 0; i < 5; i++ {
              Printf("%v: %vn", s(i))
            }
          }
        }




Going Loopy                          61                  http://slides.games-with-brains.net/
package main
        import . "fmt"

        func main() {
          s := []int{0, 2, 4, 6, 8}
          print_slice(func(i int) int { return s[i] })
        }

        func print_slice(s interface{}) {
          switch s := s.(type) {
          case func(int) int:
            for i := 0; i < 5; i++ {
              Printf("%v: %vn", s(i))
            }
          }
        }




Going Loopy                          62                  http://slides.games-with-brains.net/
package main
        import . "fmt"

        func main() {
          s := []int{0, 2, 4, 6, 8}
          print_slice(func(i int) int { return s[i] })
        }

        func print_slice(s interface{}) {
          switch s := s.(type) {
          case func(int) int:
            for i := 0; i < 5; i++ {
              Printf("%v: %vn", s(i))
            }
          }
        }




Going Loopy                          63                  http://slides.games-with-brains.net/
package main
        import . "fmt"

        func main() {
          s := []int{0, 2, 4, 6, 8}
          print_slice(func(i int) int { return s[i] })
        }

        func print_slice(s interface{}) {
          switch s := s.(type) {
          case func(int) int:
            for i := 0; i < 5; i++ {
              Printf("%v: %vn", s(i))
            }
          }
        }




Going Loopy                          64                  http://slides.games-with-brains.net/
package main
        import . "fmt"

        func main() {
          s := []int{0, 2, 4, 6, 8}
          print_slice(func(i int) int { return s[i] })
        }

        func print_slice(s interface{}) {
          switch s := s.(type) {
          case func(int) int:
            for i := 0; i < 5; i++ {
              Printf("%v: %vn", s(i))
            }
          }
        }




Going Loopy                          65                  http://slides.games-with-brains.net/
package main
        import . "fmt"

        func main() {
          s := []int{0, 2, 4, 6, 8}
          print_slice(func(i int) int { return s[i] })
        }

        func print_slice(s interface{}) {
          switch s := s.(type) {
          case func(int) int:
            for i := 0; i < 5; i++ {
              Printf("%v: %vn", s(i))
            }
          }
        }




Going Loopy                          66                  http://slides.games-with-brains.net/
package main
        import . "fmt"

        func main() {
          s := []int{0, 2, 4, 6, 8}
          print_slice(func(i int) int { return s[i] })
        }

        func print_slice(s interface{}) {
          switch s := s.(type) {
          case func(int) int:
            for i := 0; i < 5; i++ {
              Printf("%v: %vn", s(i))
            }
          }
        }




Going Loopy                          67                  http://slides.games-with-brains.net/
package main
        import . "fmt"

        func main() {
          s := []int{0, 2, 4, 6, 8}
          print_slice(func(i int) int { return s[i] })
        }

        func print_slice(s interface{}) {
          switch s := s.(type) {
          case func(int) int:
            for i := 0; i < 5; i++ {
              Printf("%v: %vn", s(i))
            }
          }
        }




Going Loopy                          68                  http://slides.games-with-brains.net/
package main
        import . "fmt"

        func main() {
          s := []int{0, 2, 4, 6, 8}
          print_slice(func(i int) int { return s[i] })
        }

        func print_slice(s interface{}) {
          switch s := s.(type) {
          case func(int) int:
            for i := 0; i < 5; i++ {
              Printf("%v: %vn", s(i))
            }
          }
        }




Going Loopy                          69                  http://slides.games-with-brains.net/
package main
        import . "fmt"

        func main() {
          s := []int{0, 2, 4, 6, 8}
          print_slice(func(i int) int { return s[i] })
        }

        func print_slice(s interface{}) {
          switch s := s.(type) {
          case func(int) int:
            for i := 0; i < 5; i++ {
              Printf("%v: %vn", s(i))
            }
          }
        }




Going Loopy                          70                  http://slides.games-with-brains.net/
upon reflection



Going Loopy         71    http://slides.games-with-brains.net/
package main
        import . "fmt"

        func main() {
          s := []int{0, 2, 4, 6, 8}
          print_values(s)
          print_values(func(i int) int { return s[i] * 2 })
        }

        func print_values(s interface{}) {
          switch s := s.(type) {
          case func(int) int:
            for i := 0; i < 5; i++ {
              Printf("%v: %vn", s(i))
            }
          case []int:
            for i, v := range s {
              Printf("%v: %vn", i, v)
            }
          }
        }




Going Loopy                          72               http://slides.games-with-brains.net/
package main
        import . "fmt"

        func main() {
          s := []int{0, 2, 4, 6, 8}
          print_values(s)
          print_values(func(i int) int { return s[i] * 2 })
        }

        func print_values(s interface{}) {
          switch s := s.(type) {
          case func(int) int:
            for i := 0; i < 5; i++ {
              Printf("%v: %vn", s(i))
            }
          case []int:
            for i, v := range s {
              Printf("%v: %vn", i, v)
            }
          }
        }




Going Loopy                          73               http://slides.games-with-brains.net/
package main
        import . "fmt"

        func main() {
          s := []int{0, 2, 4, 6, 8}
          print_values(s)
          print_values(func(i int) int { return s[i] * 2 })
        }

        func print_values(s interface{}) {
          switch s := s.(type) {
          case func(int) int:
            for i := 0; i < 5; i++ {
              Printf("%v: %vn", s(i))
            }
          case []int:
            for i, v := range s {
              Printf("%v: %vn", i, v)
            }
          }
        }




Going Loopy                          74               http://slides.games-with-brains.net/
package main
        import . "fmt"

        func main() {
          s := []int{0, 2, 4, 6, 8}
          print_values(s)
          print_values(func(i int) int { return s[i] * 2 })
        }

        func print_values(s interface{}) {
          switch s := s.(type) {
          case func(int) int:
            for i := 0; i < 5; i++ {
              Printf("%v: %vn", s(i))
            }
          case []int:
            for i, v := range s {
              Printf("%v: %vn", i, v)
            }
          }
        }




Going Loopy                          75               http://slides.games-with-brains.net/
package main
        import . "fmt"
        import . "reflect"

        func main() {
          s := []int{0, 2, 4, 6, 8}
          print_values(s)
          print_values(func(i int) int { return s[i] })
        }

        func print_values(s interface{}) {
          switch s := ValueOf(s); s.Kind() {
          case Func:
            p := []Value{ ValueOf(i) }
            for i := 0; i < 5; i++ {
              Printf("%v: %vn", s.Call(p)[0].Interface{})
            }
          case Slice:
            for i := 0; i < s.Len(); i++ {
              Printf("%v: %vn", i, s.Index(i))
            }
          }
        }


Going Loopy                           76              http://slides.games-with-brains.net/
package main
        import . "fmt"
        import . "reflect"

        func main() {
          s := []int{0, 2, 4, 6, 8}
          print_values(s)
          print_values(func(i int) int { return s[i] })
        }

        func print_values(s interface{}) {
          switch s := ValueOf(s); s.Kind() {
          case Func:
            p := []Value{ ValueOf(i) }
            for i := 0; i < 5; i++ {
              Printf("%v: %vn", s.Call(p)[0].Interface{})
            }
          case Slice:
            for i := 0; i < s.Len(); i++ {
              Printf("%v: %vn", i, s.Index(i))
            }
          }
        }


Going Loopy                           77              http://slides.games-with-brains.net/
package main
        import . "fmt"
        import . "reflect"

        func main() {
          s := []int{0, 2, 4, 6, 8}
          print_values(s)
          print_values(func(i int) int { return s[i] })
        }

        func print_values(s interface{}) {
          switch s := ValueOf(s); s.Kind() {
          case Func:
            p := []Value{ ValueOf(i) }
            for i := 0; i < 5; i++ {
              Printf("%v: %vn", s.Call(p)[0].Interface())
            }
          case Slice:
            for i := 0; i < s.Len(); i++ {
              Printf("%v: %vn", i, s.Index(i).Interface())
            }
          }
        }


Going Loopy                           78              http://slides.games-with-brains.net/
package main
        import . "fmt"
        import . "reflect"

        func main() {
          s := []int{0, 2, 4, 6, 8}
          print_values(s)
          print_values(func(i int) int { return s[i] })
        }

        func print_values(s interface{}) {
          switch s := ValueOf(s); s.Kind() {
          case Func:
            p := []Value{ ValueOf(i) }
            for i := 0; i < 5; i++ {
              Printf("%v: %vn", s.Call(p)[0].Interface())
            }
          case Slice:
            for i := 0; i < s.Len(); i++ {
              Printf("%v: %vn", i, s.Index(i).Interface())
            }
          }
        }


Going Loopy                           79              http://slides.games-with-brains.net/
package main
        import . "fmt"
        import . "reflect"

        func main() {
          s := []int{0, 2, 4, 6, 8}
          print_values(s)
          print_values(func(i int) int { return s[i] })
        }

        func print_values(s interface{}) {
          switch s := ValueOf(s); s.Kind() {
          case Func:
            p := []Value{ ValueOf(i) }
            for i := 0; i < 5; i++ {
              Printf("%v: %vn", s.Call(p)[0].Interface())
            }
          case Slice:
            for i := 0; i < s.Len(); i++ {
              Printf("%v: %vn", i, s.Index(i).Interface())
            }
          }
        }


Going Loopy                           80              http://slides.games-with-brains.net/
package main
        import . "fmt"
        import . "reflect"

        func main() {
          s := []int{0, 2, 4, 6, 8}
          print_values(s)
          print_values(func(i int) int { return s[i] })
        }

        func print_values(s interface{}) {
          switch s := ValueOf(s); s.Kind() {
          case Func:
            p := []Value{ ValueOf(i) }
            for i := 0; i < 5; i++ {
              Printf("%v: %vn", s.Call(p)[0].Interface())
            }
          case Slice:
            for i := 0; i < s.Len(); i++ {
              Printf("%v: %vn", i, s.Index(i).Interface())
            }
          }
        }


Going Loopy                           81              http://slides.games-with-brains.net/
package main
        import . "fmt"
        import . "reflect"

        func main() {
          s := []int{0, 2, 4, 6, 8}
          print_values(s)
          print_values(func(i int) int { return s[i] })
        }

        func print_values(s interface{}) {
          switch s := ValueOf(s); s.Kind() {
          case Func:
            p := []Value{ ValueOf(i) }
            for i := 0; i < 5; i++ {
              Printf("%v: %vn", s.Call(p)[0].Interface())
            }
          case Slice:
            for i := 0; i < s.Len(); i++ {
              Printf("%v: %vn", i, s.Index(i).Interface())
            }
          }
        }


Going Loopy                           82              http://slides.games-with-brains.net/
package main
        import . "fmt"
        import . "reflect"

        func main() {
          s := []int{0, 2, 4, 6, 8}
          print_values(s)
          print_values(func(i int) int { return s[i] })
        }

        func print_values(s interface{}) {
          switch s := ValueOf(s); s.Kind() {
          case Func:
            p := []Value{ ValueOf(i) }
            for i := 0; i < 5; i++ {
              Printf("%v: %vn", s.Call(p)[0].Interface())
            }
          case Slice:
            for i := 0; i < s.Len(); i++ {
              Printf("%v: %vn", i, s.Index(i).Interface())
            }
          }
        }


Going Loopy                           83              http://slides.games-with-brains.net/
package main
        import . "fmt"
        import . "reflect"

        func main() {
          s := []int{0, 2, 4, 6, 8}
          print_values(s)
          print_values(func(i int) int { return s[i] })
        }

        func print_values(s interface{}) {
          switch s := ValueOf(s); s.Kind() {
          case Func:
            p := []Value{ ValueOf(i) }
            for i := 0; i < 5; i++ {
              Printf("%v: %vn", s.Call(p)[0].Interface())
            }
          case Slice:
            for i := 0; i < s.Len(); i++ {
              Printf("%v: %vn", i, s.Index(i).Interface())
            }
          }
        }


Going Loopy                           84              http://slides.games-with-brains.net/
package main
        import . "fmt"
        import . "reflect"

        func main() {
          s := []int{0, 2, 4, 6, 8}
          print_values(s)
          print_values(func(i int) int { return s[i] })
        }

        func print_values(s interface{}) {
          switch s := ValueOf(s); s.Kind() {
          case Func:
            p := []Value{ ValueOf(i) }
            for i := 0; i < 5; i++ {
              Printf("%v: %vn", s.Call(p)[0].Interface())
            }
          case Slice:
            for i := 0; i < s.Len(); i++ {
              Printf("%v: %vn", i, s.Index(i).Interface())
            }
          }
        }


Going Loopy                           85              http://slides.games-with-brains.net/
package main
        import . "fmt"
        import . "reflect"

        func main() {
          s := []int{0, 2, 4, 6, 8}
          print_values(s)
          print_values(func(i int) int { return s[i] })
        }

        func print_values(s interface{}) {
          switch s := ValueOf(s); s.Kind() {
          case Func:
            p := []Value{ ValueOf(i) }
            for i := 0; i < 5; i++ {
              Printf("%v: %vn", s.Call(p)[0].Interface())
            }
          case Slice:
            for i := 0; i < s.Len(); i++ {
              Printf("%v: %vn", i, s.Index(i).Interface())
            }
          }
        }


Going Loopy                           86              http://slides.games-with-brains.net/
package main
        import . "fmt"
        import . "reflect"

        func main() {
          s := []int{0, 2, 4, 6, 8}
          print_values(s)
          print_values(func(i int) int { return s[i] })
        }

        func print_values(s interface{}) {
          switch s := ValueOf(s); s.Kind() {
          case Func:
            p := []Value{ ValueOf(i) }
            for i := 0; i < 5; i++ {
              Printf("%v: %vn", s.Call(p)[0].Interface())
            }
          case Slice:
            for i := 0; i < s.Len(); i++ {
              Printf("%v: %vn", i, s.Index(i).Interface())
            }
          }
        }


Going Loopy                           87              http://slides.games-with-brains.net/
package main
        import . "fmt"
        import . "reflect"

        func main() {
          s := []int{0, 2, 4, 6, 8}
          print_values(s)
          print_values(func(i int) int { return s[i] })
        }

        func print_values(s interface{}) {
          switch s := ValueOf(s); s.Kind() {
          case Func:
            p := []Value{ ValueOf(i) }
            for i := 0; i < 5; i++ {
              Printf("%v: %vn", s.Call(p)[0].Interface())
            }
          case Slice:
            for i := 0; i < s.Len(); i++ {
              Printf("%v: %vn", i, s.Index(i).Interface())
            }
          }
        }


Going Loopy                           88              http://slides.games-with-brains.net/
package main
        import . "fmt"
        import . "reflect"

        func main() {
          s := []int{0, 2, 4, 6, 8}
          print_values(s)
          print_values(func(i int) int { return s[i] })
        }

        func print_values(s interface{}) {
          switch s := ValueOf(s); s.Kind() {
          case Func:
            p := []Value{ ValueOf(i) }
            for i := 0; i < 5; i++ {
              Printf("%v: %vn", s.Call(p)[0].Interface())
            }
          case Slice:
            for i := 0; i < s.Len(); i++ {
              Printf("%v: %vn", i, s.Index(i).Interface())
            }
          }
        }


Going Loopy                           89              http://slides.games-with-brains.net/
http://golang.org/
       #golang

More Related Content

What's hot

Templates don’t need to break the browser by Nikolas Martens
Templates don’t need to break the browser by Nikolas Martens  Templates don’t need to break the browser by Nikolas Martens
Templates don’t need to break the browser by Nikolas Martens Codemotion
 
Templating you're doing it wrong - Nikolas Martens - Codemotion Amsterdam 2017
Templating you're doing it wrong - Nikolas Martens - Codemotion Amsterdam 2017Templating you're doing it wrong - Nikolas Martens - Codemotion Amsterdam 2017
Templating you're doing it wrong - Nikolas Martens - Codemotion Amsterdam 2017Codemotion
 
mobl: Een DSL voor mobiele applicatieontwikkeling
mobl: Een DSL voor mobiele applicatieontwikkelingmobl: Een DSL voor mobiele applicatieontwikkeling
mobl: Een DSL voor mobiele applicatieontwikkelingDevnology
 
Go for the paranoid network programmer
Go for the paranoid network programmerGo for the paranoid network programmer
Go for the paranoid network programmerEleanor McHugh
 
The Ring programming language version 1.4 book - Part 15 of 30
The Ring programming language version 1.4 book - Part 15 of 30The Ring programming language version 1.4 book - Part 15 of 30
The Ring programming language version 1.4 book - Part 15 of 30Mahmoud Samir Fayed
 
Go for the would be network programmer
Go for the would be network programmerGo for the would be network programmer
Go for the would be network programmerEleanor McHugh
 
Python na Infraestrutura 
MySQL do Facebook

Python na Infraestrutura 
MySQL do Facebook
Python na Infraestrutura 
MySQL do Facebook

Python na Infraestrutura 
MySQL do Facebook
Artur Rodrigues
 
Flow of events during Media Player creation in Android
Flow of events during Media Player creation in AndroidFlow of events during Media Player creation in Android
Flow of events during Media Player creation in AndroidSomenath Mukhopadhyay
 
Pemrograman Python untuk Pemula
Pemrograman Python untuk PemulaPemrograman Python untuk Pemula
Pemrograman Python untuk PemulaOon Arfiandwi
 
Javasccript MV* frameworks
Javasccript MV* frameworksJavasccript MV* frameworks
Javasccript MV* frameworksKerry Buckley
 
Model-Based Testing: Why, What, How
Model-Based Testing: Why, What, HowModel-Based Testing: Why, What, How
Model-Based Testing: Why, What, HowBob Binder
 
Implementing virtual machines in go & c 2018 redux
Implementing virtual machines in go & c 2018 reduxImplementing virtual machines in go & c 2018 redux
Implementing virtual machines in go & c 2018 reduxEleanor McHugh
 
Go for the paranoid network programmer, 3rd edition
Go for the paranoid network programmer, 3rd editionGo for the paranoid network programmer, 3rd edition
Go for the paranoid network programmer, 3rd editionEleanor McHugh
 
The Browser Environment - A Systems Programmer's Perspective
The Browser Environment - A Systems Programmer's PerspectiveThe Browser Environment - A Systems Programmer's Perspective
The Browser Environment - A Systems Programmer's PerspectiveEleanor McHugh
 
Call Return Exploration
Call Return ExplorationCall Return Exploration
Call Return ExplorationPat Hawks
 
Jython: Python para la plataforma Java (JRSL 09)
Jython: Python para la plataforma Java (JRSL 09)Jython: Python para la plataforma Java (JRSL 09)
Jython: Python para la plataforma Java (JRSL 09)Leonardo Soto
 

What's hot (19)

Templates don’t need to break the browser by Nikolas Martens
Templates don’t need to break the browser by Nikolas Martens  Templates don’t need to break the browser by Nikolas Martens
Templates don’t need to break the browser by Nikolas Martens
 
Templating you're doing it wrong - Nikolas Martens - Codemotion Amsterdam 2017
Templating you're doing it wrong - Nikolas Martens - Codemotion Amsterdam 2017Templating you're doing it wrong - Nikolas Martens - Codemotion Amsterdam 2017
Templating you're doing it wrong - Nikolas Martens - Codemotion Amsterdam 2017
 
mobl: Een DSL voor mobiele applicatieontwikkeling
mobl: Een DSL voor mobiele applicatieontwikkelingmobl: Een DSL voor mobiele applicatieontwikkeling
mobl: Een DSL voor mobiele applicatieontwikkeling
 
Go for the paranoid network programmer
Go for the paranoid network programmerGo for the paranoid network programmer
Go for the paranoid network programmer
 
The Ring programming language version 1.4 book - Part 15 of 30
The Ring programming language version 1.4 book - Part 15 of 30The Ring programming language version 1.4 book - Part 15 of 30
The Ring programming language version 1.4 book - Part 15 of 30
 
Go for the would be network programmer
Go for the would be network programmerGo for the would be network programmer
Go for the would be network programmer
 
Python na Infraestrutura 
MySQL do Facebook

Python na Infraestrutura 
MySQL do Facebook
Python na Infraestrutura 
MySQL do Facebook

Python na Infraestrutura 
MySQL do Facebook

 
Flow of events during Media Player creation in Android
Flow of events during Media Player creation in AndroidFlow of events during Media Player creation in Android
Flow of events during Media Player creation in Android
 
Pemrograman Python untuk Pemula
Pemrograman Python untuk PemulaPemrograman Python untuk Pemula
Pemrograman Python untuk Pemula
 
Javasccript MV* frameworks
Javasccript MV* frameworksJavasccript MV* frameworks
Javasccript MV* frameworks
 
Model-Based Testing: Why, What, How
Model-Based Testing: Why, What, HowModel-Based Testing: Why, What, How
Model-Based Testing: Why, What, How
 
Implementing virtual machines in go & c 2018 redux
Implementing virtual machines in go & c 2018 reduxImplementing virtual machines in go & c 2018 redux
Implementing virtual machines in go & c 2018 redux
 
Groovy kind of test
Groovy kind of testGroovy kind of test
Groovy kind of test
 
EUnit in Practice(Japanese)
EUnit in Practice(Japanese)EUnit in Practice(Japanese)
EUnit in Practice(Japanese)
 
Meck
MeckMeck
Meck
 
Go for the paranoid network programmer, 3rd edition
Go for the paranoid network programmer, 3rd editionGo for the paranoid network programmer, 3rd edition
Go for the paranoid network programmer, 3rd edition
 
The Browser Environment - A Systems Programmer's Perspective
The Browser Environment - A Systems Programmer's PerspectiveThe Browser Environment - A Systems Programmer's Perspective
The Browser Environment - A Systems Programmer's Perspective
 
Call Return Exploration
Call Return ExplorationCall Return Exploration
Call Return Exploration
 
Jython: Python para la plataforma Java (JRSL 09)
Jython: Python para la plataforma Java (JRSL 09)Jython: Python para la plataforma Java (JRSL 09)
Jython: Python para la plataforma Java (JRSL 09)
 

Similar to Going Loopy

going loopy - adventures in iteration with go - Eleanor McHugh - Codemotion M...
going loopy - adventures in iteration with go - Eleanor McHugh - Codemotion M...going loopy - adventures in iteration with go - Eleanor McHugh - Codemotion M...
going loopy - adventures in iteration with go - Eleanor McHugh - Codemotion M...Codemotion
 
Python-GTK
Python-GTKPython-GTK
Python-GTKYuren Ju
 
When Bad Things Come In Good Packages
When Bad Things Come In Good PackagesWhen Bad Things Come In Good Packages
When Bad Things Come In Good PackagesSaumil Shah
 
Go vs C++ - CppRussia 2019 Piter BoF
Go vs C++ - CppRussia 2019 Piter BoFGo vs C++ - CppRussia 2019 Piter BoF
Go vs C++ - CppRussia 2019 Piter BoFTimur Safin
 
Testing CLI tools with Go
Testing CLI tools with GoTesting CLI tools with Go
Testing CLI tools with GoRicardo Gerardi
 
Pattern printing-in-c(Jaydip Kikani)
Pattern printing-in-c(Jaydip Kikani)Pattern printing-in-c(Jaydip Kikani)
Pattern printing-in-c(Jaydip Kikani)Jaydip JK
 
Goptuna Distributed Bayesian Optimization Framework at Go Conference 2019 Autumn
Goptuna Distributed Bayesian Optimization Framework at Go Conference 2019 AutumnGoptuna Distributed Bayesian Optimization Framework at Go Conference 2019 Autumn
Goptuna Distributed Bayesian Optimization Framework at Go Conference 2019 AutumnMasashi Shibata
 
Python Peculiarities
Python PeculiaritiesPython Peculiarities
Python Peculiaritiesnoamt
 
Go: It's Not Just For Google
Go: It's Not Just For GoogleGo: It's Not Just For Google
Go: It's Not Just For GoogleEleanor McHugh
 
Advanced Debugging Using Java Bytecodes
Advanced Debugging Using Java BytecodesAdvanced Debugging Using Java Bytecodes
Advanced Debugging Using Java BytecodesGanesh Samarthyam
 
2016 gunma.web games-and-asm.js
2016 gunma.web games-and-asm.js2016 gunma.web games-and-asm.js
2016 gunma.web games-and-asm.jsNoritada Shimizu
 
Assignment on Numerical Method C Code
Assignment on Numerical Method C CodeAssignment on Numerical Method C Code
Assignment on Numerical Method C CodeSyed Ahmed Zaki
 

Similar to Going Loopy (20)

going loopy - adventures in iteration with go - Eleanor McHugh - Codemotion M...
going loopy - adventures in iteration with go - Eleanor McHugh - Codemotion M...going loopy - adventures in iteration with go - Eleanor McHugh - Codemotion M...
going loopy - adventures in iteration with go - Eleanor McHugh - Codemotion M...
 
Introduction to Go for Java Programmers
Introduction to Go for Java ProgrammersIntroduction to Go for Java Programmers
Introduction to Go for Java Programmers
 
Vcs17
Vcs17Vcs17
Vcs17
 
Python-GTK
Python-GTKPython-GTK
Python-GTK
 
Initial Java Core Concept
Initial Java Core ConceptInitial Java Core Concept
Initial Java Core Concept
 
When Bad Things Come In Good Packages
When Bad Things Come In Good PackagesWhen Bad Things Come In Good Packages
When Bad Things Come In Good Packages
 
BCSL 058 solved assignment
BCSL 058 solved assignmentBCSL 058 solved assignment
BCSL 058 solved assignment
 
Go vs C++ - CppRussia 2019 Piter BoF
Go vs C++ - CppRussia 2019 Piter BoFGo vs C++ - CppRussia 2019 Piter BoF
Go vs C++ - CppRussia 2019 Piter BoF
 
Testing CLI tools with Go
Testing CLI tools with GoTesting CLI tools with Go
Testing CLI tools with Go
 
Pattern printing-in-c(Jaydip Kikani)
Pattern printing-in-c(Jaydip Kikani)Pattern printing-in-c(Jaydip Kikani)
Pattern printing-in-c(Jaydip Kikani)
 
Unix Programs
Unix ProgramsUnix Programs
Unix Programs
 
Goptuna Distributed Bayesian Optimization Framework at Go Conference 2019 Autumn
Goptuna Distributed Bayesian Optimization Framework at Go Conference 2019 AutumnGoptuna Distributed Bayesian Optimization Framework at Go Conference 2019 Autumn
Goptuna Distributed Bayesian Optimization Framework at Go Conference 2019 Autumn
 
Python Peculiarities
Python PeculiaritiesPython Peculiarities
Python Peculiarities
 
Go: It's Not Just For Google
Go: It's Not Just For GoogleGo: It's Not Just For Google
Go: It's Not Just For Google
 
C programs pbq final
C programs pbq finalC programs pbq final
C programs pbq final
 
Advanced Debugging Using Java Bytecodes
Advanced Debugging Using Java BytecodesAdvanced Debugging Using Java Bytecodes
Advanced Debugging Using Java Bytecodes
 
2016 gunma.web games-and-asm.js
2016 gunma.web games-and-asm.js2016 gunma.web games-and-asm.js
2016 gunma.web games-and-asm.js
 
Assignment on Numerical Method C Code
Assignment on Numerical Method C CodeAssignment on Numerical Method C Code
Assignment on Numerical Method C Code
 
C
CC
C
 
python codes
python codespython codes
python codes
 

More from Eleanor McHugh

[2023] Putting the R! in R&D.pdf
[2023] Putting the R! in R&D.pdf[2023] Putting the R! in R&D.pdf
[2023] Putting the R! in R&D.pdfEleanor McHugh
 
Generics, Reflection, and Efficient Collections
Generics, Reflection, and Efficient CollectionsGenerics, Reflection, and Efficient Collections
Generics, Reflection, and Efficient CollectionsEleanor McHugh
 
The Relevance of Liveness - Biometrics and Data Integrity
The Relevance of Liveness - Biometrics and Data IntegrityThe Relevance of Liveness - Biometrics and Data Integrity
The Relevance of Liveness - Biometrics and Data IntegrityEleanor McHugh
 
The Browser Environment - A Systems Programmer's Perspective [sinatra edition]
The Browser Environment - A Systems Programmer's Perspective [sinatra edition]The Browser Environment - A Systems Programmer's Perspective [sinatra edition]
The Browser Environment - A Systems Programmer's Perspective [sinatra edition]Eleanor McHugh
 
An introduction to functional programming with Go [redux]
An introduction to functional programming with Go [redux]An introduction to functional programming with Go [redux]
An introduction to functional programming with Go [redux]Eleanor McHugh
 
Identity & trust in Monitored Spaces
Identity & trust in Monitored SpacesIdentity & trust in Monitored Spaces
Identity & trust in Monitored SpacesEleanor McHugh
 
Don't Ask, Don't Tell - The Virtues of Privacy By Design
Don't Ask, Don't Tell - The Virtues of Privacy By DesignDon't Ask, Don't Tell - The Virtues of Privacy By Design
Don't Ask, Don't Tell - The Virtues of Privacy By DesignEleanor McHugh
 
Don't ask, don't tell the virtues of privacy by design
Don't ask, don't tell   the virtues of privacy by designDon't ask, don't tell   the virtues of privacy by design
Don't ask, don't tell the virtues of privacy by designEleanor McHugh
 
Anonymity, identity, trust
Anonymity, identity, trustAnonymity, identity, trust
Anonymity, identity, trustEleanor McHugh
 
Distributed Ledgers: Anonymity & Immutability at Scale
Distributed Ledgers: Anonymity & Immutability at ScaleDistributed Ledgers: Anonymity & Immutability at Scale
Distributed Ledgers: Anonymity & Immutability at ScaleEleanor McHugh
 
Finding a useful outlet for my many Adventures in go
Finding a useful outlet for my many Adventures in goFinding a useful outlet for my many Adventures in go
Finding a useful outlet for my many Adventures in goEleanor McHugh
 
Anonymity, trust, accountability
Anonymity, trust, accountabilityAnonymity, trust, accountability
Anonymity, trust, accountabilityEleanor McHugh
 
Implementing Virtual Machines in Ruby & C
Implementing Virtual Machines in Ruby & CImplementing Virtual Machines in Ruby & C
Implementing Virtual Machines in Ruby & CEleanor McHugh
 
Implementing Software Machines in C and Go
Implementing Software Machines in C and GoImplementing Software Machines in C and Go
Implementing Software Machines in C and GoEleanor McHugh
 
Implementing Software Machines in Go and C
Implementing Software Machines in Go and CImplementing Software Machines in Go and C
Implementing Software Machines in Go and CEleanor McHugh
 
Encrypt all transports
Encrypt all transportsEncrypt all transports
Encrypt all transportsEleanor McHugh
 
Privacy is always a requirement
Privacy is always a requirementPrivacy is always a requirement
Privacy is always a requirementEleanor McHugh
 
Hybrid Cryptography with examples in Ruby and Go
Hybrid Cryptography with examples in Ruby and GoHybrid Cryptography with examples in Ruby and Go
Hybrid Cryptography with examples in Ruby and GoEleanor McHugh
 

More from Eleanor McHugh (20)

[2023] Putting the R! in R&D.pdf
[2023] Putting the R! in R&D.pdf[2023] Putting the R! in R&D.pdf
[2023] Putting the R! in R&D.pdf
 
Generics, Reflection, and Efficient Collections
Generics, Reflection, and Efficient CollectionsGenerics, Reflection, and Efficient Collections
Generics, Reflection, and Efficient Collections
 
The Relevance of Liveness - Biometrics and Data Integrity
The Relevance of Liveness - Biometrics and Data IntegrityThe Relevance of Liveness - Biometrics and Data Integrity
The Relevance of Liveness - Biometrics and Data Integrity
 
The Browser Environment - A Systems Programmer's Perspective [sinatra edition]
The Browser Environment - A Systems Programmer's Perspective [sinatra edition]The Browser Environment - A Systems Programmer's Perspective [sinatra edition]
The Browser Environment - A Systems Programmer's Perspective [sinatra edition]
 
An introduction to functional programming with Go [redux]
An introduction to functional programming with Go [redux]An introduction to functional programming with Go [redux]
An introduction to functional programming with Go [redux]
 
Identity & trust in Monitored Spaces
Identity & trust in Monitored SpacesIdentity & trust in Monitored Spaces
Identity & trust in Monitored Spaces
 
Don't Ask, Don't Tell - The Virtues of Privacy By Design
Don't Ask, Don't Tell - The Virtues of Privacy By DesignDon't Ask, Don't Tell - The Virtues of Privacy By Design
Don't Ask, Don't Tell - The Virtues of Privacy By Design
 
Don't ask, don't tell the virtues of privacy by design
Don't ask, don't tell   the virtues of privacy by designDon't ask, don't tell   the virtues of privacy by design
Don't ask, don't tell the virtues of privacy by design
 
Anonymity, identity, trust
Anonymity, identity, trustAnonymity, identity, trust
Anonymity, identity, trust
 
Distributed Ledgers: Anonymity & Immutability at Scale
Distributed Ledgers: Anonymity & Immutability at ScaleDistributed Ledgers: Anonymity & Immutability at Scale
Distributed Ledgers: Anonymity & Immutability at Scale
 
Finding a useful outlet for my many Adventures in go
Finding a useful outlet for my many Adventures in goFinding a useful outlet for my many Adventures in go
Finding a useful outlet for my many Adventures in go
 
Anonymity, trust, accountability
Anonymity, trust, accountabilityAnonymity, trust, accountability
Anonymity, trust, accountability
 
Implementing Virtual Machines in Ruby & C
Implementing Virtual Machines in Ruby & CImplementing Virtual Machines in Ruby & C
Implementing Virtual Machines in Ruby & C
 
Implementing Software Machines in C and Go
Implementing Software Machines in C and GoImplementing Software Machines in C and Go
Implementing Software Machines in C and Go
 
Implementing Software Machines in Go and C
Implementing Software Machines in Go and CImplementing Software Machines in Go and C
Implementing Software Machines in Go and C
 
Encrypt all transports
Encrypt all transportsEncrypt all transports
Encrypt all transports
 
Whispered secrets
Whispered secretsWhispered secrets
Whispered secrets
 
Whispered secrets
Whispered secretsWhispered secrets
Whispered secrets
 
Privacy is always a requirement
Privacy is always a requirementPrivacy is always a requirement
Privacy is always a requirement
 
Hybrid Cryptography with examples in Ruby and Go
Hybrid Cryptography with examples in Ruby and GoHybrid Cryptography with examples in Ruby and Go
Hybrid Cryptography with examples in Ruby and Go
 

Recently uploaded

Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 

Recently uploaded (20)

Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 

Going Loopy

  • 1. Going Loopy adventures in iteration with Google Go Eleanor McHugh Going Loopy 1 http://slides.games-with-brains.net/
  • 2. the conditional loop Going Loopy 2 http://slides.games-with-brains.net/
  • 3. package main import "fmt" func main() { s := []int{0, 2, 4, 6, 8} for i := 0; i < len(s); i++ { fmt.Printf("%v: %vn", i, s[i]) } } Going Loopy 3 http://slides.games-with-brains.net/
  • 4. package main import "fmt" func main() { s := []int{0, 2, 4, 6, 8} for i := 0; i < len(s); i++ { fmt.Printf("%v: %vn", i, s[i]) } } 0: 0 1: 2 2: 4 3: 6 4: 8 Going Loopy 4 http://slides.games-with-brains.net/
  • 5. package main import "fmt" func main() { s := []int{0, 2, 4, 6, 8} for i := 0; i < len(s); i++ { fmt.Printf("%v: %vn", i, s[i]) } } Going Loopy 5 http://slides.games-with-brains.net/
  • 6. package main import "fmt" func main() { s := []int{0, 2, 4, 6, 8} for i := 0; i < len(s); i++ { fmt.Printf("%v: %vn", i, s[i]) } } Going Loopy 6 http://slides.games-with-brains.net/
  • 7. package main import "fmt" func main() { s := []int{0, 2, 4, 6, 8} for i := 0; i < len(s); i++ { fmt.Printf("%v: %vn", i, s[i]) } } Going Loopy 7 http://slides.games-with-brains.net/
  • 8. package main import . "fmt" func main() { s := []int{0, 2, 4, 6, 8} for i := 0; i < len(s); i++ { Printf("%v: %vn", i, s[i]) } } Going Loopy 8 http://slides.games-with-brains.net/
  • 9. package main import . "fmt" func main() { s := []int{0, 2, 4, 6, 8} for i := 0; i < len(s); i++ { Printf("%v: %vn", i, s[i]) } } Going Loopy 9 http://slides.games-with-brains.net/
  • 10. package main import . "fmt" func main() { s := []int{0, 2, 4, 6, 8} for i := 0; i < len(s); i++ { Printf("%v: %vn", i, s[i]) } } Going Loopy 10 http://slides.games-with-brains.net/
  • 11. package main import . "fmt" func main() { s := []int{0, 2, 4, 6, 8} for i := 0; i < len(s); i++ { Printf("%v: %vn", i, s[i]) } } Going Loopy 11 http://slides.games-with-brains.net/
  • 12. package main import . "fmt" func main() { s := []int{0, 2, 4, 6, 8} for i := 0; i < len(s); i++ { Printf("%v: %vn", i, s[i]) } } Going Loopy 12 http://slides.games-with-brains.net/
  • 13. package main import . "fmt" func main() { s := []int{0, 2, 4, 6, 8} for i := 0; i < len(s); i++ { Printf("%v: %vn", i, s[i]) } } Going Loopy 13 http://slides.games-with-brains.net/
  • 14. package main import . "fmt" func main() { s := []int{0, 2, 4, 6, 8} for i := 0; i < len(s); i++ { Printf("%v: %vn", i, s[i]) } } Going Loopy 14 http://slides.games-with-brains.net/
  • 15. package main import . "fmt" func main() { s := []int{0, 2, 4, 6, 8} for i := 0; i < len(s); i++ { Printf("%v: %vn", i, s[i]) } } Going Loopy 15 http://slides.games-with-brains.net/
  • 16. package main import . "fmt" func main() { s := []int{0, 2, 4, 6, 8} for i := 0; i < len(s); i++ { Printf("%v: %vn", i, s[i]) } } Going Loopy 16 http://slides.games-with-brains.net/
  • 17. package main import . "fmt" func main() { s := []int{0, 2, 4, 6, 8} for i := 0; i < len(s); i++ { Printf("%v: %vn", i, s[i]) } } Going Loopy 17 http://slides.games-with-brains.net/
  • 18. package main import . "fmt" func main() { s := []int{0, 2, 4, 6, 8} for i := 0; i < len(s); i++ { Printf("%v: %vn", i, s[i]) } } Going Loopy 18 http://slides.games-with-brains.net/
  • 19. package main import . "fmt" func main() { s := []int{0, 2, 4, 6, 8} for i := 0; i < len(s); i++ { Printf("%v: %vn", i, s[i]) } } Going Loopy 19 http://slides.games-with-brains.net/
  • 20. package main import . "fmt" func main() { s := []int{0, 2, 4, 6, 8} for i := 0; i < len(s); i++ { Printf("%v: %vn", i, s[i]) } } Going Loopy 20 http://slides.games-with-brains.net/
  • 21. package main import . "fmt" func main() { s := []int{0, 2, 4, 6, 8} for i := 0; i < len(s); i++ { Printf("%v: %vn", i, s[i]) } } Going Loopy 21 http://slides.games-with-brains.net/
  • 22. package main import . "fmt" func main() { s := []int{0, 2, 4, 6, 8} for i := 0; i < len(s); i++ { Printf("%v: %vn", i, s[i]) } } Going Loopy 22 http://slides.games-with-brains.net/
  • 23. the infinite loop Going Loopy 23 http://slides.games-with-brains.net/
  • 24. package main import . "fmt" func main() { defer func() { recover() }() s := []int{0, 2, 4, 6, 8} for i := 0; ; i++ { Printf("%v: %vn", i, s[i]) } } Going Loopy 24 http://slides.games-with-brains.net/
  • 25. package main import . "fmt" func main() { defer func() { recover() }() s := []int{0, 2, 4, 6, 8} for i := 0; ; i++ { Printf("%v: %vn", i, s[i]) } } Going Loopy 25 http://slides.games-with-brains.net/
  • 26. package main import . "fmt" func main() { defer func() { recover() }() s := []int{0, 2, 4, 6, 8} for i := 0; ; i++ { Printf("%v: %vn", i, s[i]) } } Going Loopy 26 http://slides.games-with-brains.net/
  • 27. package main import . "fmt" func main() { defer func() { recover() }() s := []int{0, 2, 4, 6, 8} for i := 0; ; i++ { Printf("%v: %vn", i, s[i]) } } Going Loopy 27 http://slides.games-with-brains.net/
  • 28. package main import . "fmt" func main() { defer func() { recover() }() s := []int{0, 2, 4, 6, 8} for i := 0; ; i++ { Printf("%v: %vn", i, s[i]) } } Going Loopy 28 http://slides.games-with-brains.net/
  • 29. the range Going Loopy 29 http://slides.games-with-brains.net/
  • 30. package main import . "fmt" func main() { s := []int{0, 2, 4, 6, 8} for i, v := range s { Printf("%v: %vn", i, v) } } Going Loopy 30 http://slides.games-with-brains.net/
  • 31. package main import . "fmt" func main() { s := []int{0, 2, 4, 6, 8} for i, v := range s { Printf("%v: %vn", i, v) } } Going Loopy 31 http://slides.games-with-brains.net/
  • 32. package main import . "fmt" func main() { s := []int{0, 2, 4, 6, 8} for i, v := range s { Printf("%v: %vn", i, v) } } Going Loopy 32 http://slides.games-with-brains.net/
  • 33. package main import . "fmt" func main() { s := []int{0, 2, 4, 6, 8} for i, v := range s { Printf("%v: %vn", i, v) } } Going Loopy 33 http://slides.games-with-brains.net/
  • 34. package main import . "fmt" func main() { s := []int{0, 2, 4, 6, 8} for i, v := range s { Printf("%v: %vn", i, v) } } Going Loopy 34 http://slides.games-with-brains.net/
  • 35. package main import . "fmt" func main() { s := []int{0, 2, 4, 6, 8} for i, v := range s { Printf("%v: %vn", i, v) } } Going Loopy 35 http://slides.games-with-brains.net/
  • 36. a functional interlude Going Loopy 36 http://slides.games-with-brains.net/
  • 37. package main import . "fmt" func main() { print_slice([]int{0, 2, 4, 6, 8}) } func print_slice(s []int) { for i, v := range s { Printf("%v: %vn", i, v) } } Going Loopy 37 http://slides.games-with-brains.net/
  • 38. package main import . "fmt" func main() { print_slice([]int{0, 2, 4, 6, 8}) } func print_slice(s []int) { for i, v := range s { Printf("%v: %vn", i, v) } } Going Loopy 38 http://slides.games-with-brains.net/
  • 39. package main import . "fmt" func main() { print_slice([]int{0, 2, 4, 6, 8}) } func print_slice(s []int) { for i, v := range s { Printf("%v: %vn", i, v) } } Going Loopy 39 http://slides.games-with-brains.net/
  • 40. package main import . "fmt" func main() { print_slice([]int{0, 2, 4, 6, 8}) } func print_slice(s []int) { for i, v := range s { Printf("%v: %vn", i, v) } } Going Loopy 40 http://slides.games-with-brains.net/
  • 41. package main import . "fmt" func main() { print_slice(0, 2, 4, 6, 8) } func print_slice(s ...int) { for i, v := range s { Printf("%v: %vn", i, v) } } Going Loopy 41 http://slides.games-with-brains.net/
  • 42. package main import . "fmt" func main() { print_slice(0, 2, 4, 6, 8) } func print_slice(s ...int) { for i, v := range s { Printf("%v: %vn", i, v) } } Going Loopy 42 http://slides.games-with-brains.net/
  • 43. package main import . "fmt" func main() { print_slice(0, 2, 4, 6, 8) } func print_slice(s ...int) { for i, v := range s { Printf("%v: %vn", i, v) } } Going Loopy 43 http://slides.games-with-brains.net/
  • 44. asserting type Going Loopy 44 http://slides.games-with-brains.net/
  • 45. package main import . "fmt" func main() { print_slice([]int{0, 2, 4, 6, 8}) } func print_slice(s interface{}) { for i, v := range s.([]int) { Printf("%v: %vn", i, v) } } Going Loopy 45 http://slides.games-with-brains.net/
  • 46. package main import . "fmt" func main() { print_slice([]int{0, 2, 4, 6, 8}) } func print_slice(s interface{}) { for i, v := range s.([]int) { Printf("%v: %vn", i, v) } } Going Loopy 46 http://slides.games-with-brains.net/
  • 47. package main import . "fmt" func main() { print_slice([]int{0, 2, 4, 6, 8}) } func print_slice(s interface{}) { for i, v := range s.([]int) { Printf("%v: %vn", i, v) } } Going Loopy 47 http://slides.games-with-brains.net/
  • 48. package main import . "fmt" func main() { print_slice([]int{0, 2, 4, 6, 8}) } func print_slice(s interface{}) { if s, ok := s.([]int); ok { for i, v := range s { Printf("%v: %vn", i, v) } } } Going Loopy 48 http://slides.games-with-brains.net/
  • 49. package main import . "fmt" func main() { print_slice([]int{0, 2, 4, 6, 8}) } func print_slice(s interface{}) { if s, ok := s.([]int); ok { for i, v := range s { Printf("%v: %vn", i, v) } } } Going Loopy 49 http://slides.games-with-brains.net/
  • 50. package main import . "fmt" func main() { print_slice([]int{0, 2, 4, 6, 8}) } func print_slice(s interface{}) { if s, ok := s.([]int); ok { for i, v := range s { Printf("%v: %vn", i, v) } } } Going Loopy 50 http://slides.games-with-brains.net/
  • 51. package main import . "fmt" func main() { print_slice([]int{0, 2, 4, 6, 8}) } func print_slice(s interface{}) { if s, ok := s.([]int); ok { for i, v := range s { Printf("%v: %vn", i, v) } } } Going Loopy 51 http://slides.games-with-brains.net/
  • 52. package main import . "fmt" func main() { print_slice([]int{0, 2, 4, 6, 8}) } func print_slice(s interface{}) { if s, ok := s.([]int); ok { for i, v := range s { Printf("%v: %vn", i, v) } } } Going Loopy 52 http://slides.games-with-brains.net/
  • 53. package main import . "fmt" func main() { print_slice([]int{0, 2, 4, 6, 8}) } func print_slice(s interface{}) { if s, ok := s.([]int); ok { for i, v := range s { Printf("%v: %vn", i, v) } } } Going Loopy 53 http://slides.games-with-brains.net/
  • 54. package main import . "fmt" func main() { print_slice([]int{0, 2, 4, 6, 8}) } func print_slice(s interface{}) { switch s := s.(type) { case []int: for i, v := range s { Printf("%v: %vn", i, v) } } } Going Loopy 54 http://slides.games-with-brains.net/
  • 55. package main import . "fmt" func main() { print_slice([]int{0, 2, 4, 6, 8}) } func print_slice(s interface{}) { switch s := s.(type) { case []int: for i, v := range s { Printf("%v: %vn", i, v) } } } Going Loopy 55 http://slides.games-with-brains.net/
  • 56. package main import . "fmt" func main() { print_slice([]int{0, 2, 4, 6, 8}) } func print_slice(s interface{}) { switch s := s.(type) { case []int: for i, v := range s { Printf("%v: %vn", i, v) } } } Going Loopy 56 http://slides.games-with-brains.net/
  • 57. package main import . "fmt" func main() { print_slice([]int{0, 2, 4, 6, 8}) } func print_slice(s interface{}) { switch s := s.(type) { case []int: for i, v := range s { Printf("%v: %vn", i, v) } } } Going Loopy 57 http://slides.games-with-brains.net/
  • 58. package main import . "fmt" func main() { print_slice([]int{0, 2, 4, 6, 8}) } func print_slice(s interface{}) { switch s := s.(type) { case []int: for i, v := range s { Printf("%v: %vn", i, v) } } } Going Loopy 58 http://slides.games-with-brains.net/
  • 59. package main import . "fmt" func main() { print_slice([]int{0, 2, 4, 6, 8}) } func print_slice(s interface{}) { switch s := s.(type) { case []int: for i, v := range s { Printf("%v: %vn", i, v) } } } Going Loopy 59 http://slides.games-with-brains.net/
  • 60. closures Going Loopy 60 http://slides.games-with-brains.net/
  • 61. package main import . "fmt" func main() { s := []int{0, 2, 4, 6, 8} print_slice(func(i int) int { return s[i] }) } func print_slice(s interface{}) { switch s := s.(type) { case func(int) int: for i := 0; i < 5; i++ { Printf("%v: %vn", s(i)) } } } Going Loopy 61 http://slides.games-with-brains.net/
  • 62. package main import . "fmt" func main() { s := []int{0, 2, 4, 6, 8} print_slice(func(i int) int { return s[i] }) } func print_slice(s interface{}) { switch s := s.(type) { case func(int) int: for i := 0; i < 5; i++ { Printf("%v: %vn", s(i)) } } } Going Loopy 62 http://slides.games-with-brains.net/
  • 63. package main import . "fmt" func main() { s := []int{0, 2, 4, 6, 8} print_slice(func(i int) int { return s[i] }) } func print_slice(s interface{}) { switch s := s.(type) { case func(int) int: for i := 0; i < 5; i++ { Printf("%v: %vn", s(i)) } } } Going Loopy 63 http://slides.games-with-brains.net/
  • 64. package main import . "fmt" func main() { s := []int{0, 2, 4, 6, 8} print_slice(func(i int) int { return s[i] }) } func print_slice(s interface{}) { switch s := s.(type) { case func(int) int: for i := 0; i < 5; i++ { Printf("%v: %vn", s(i)) } } } Going Loopy 64 http://slides.games-with-brains.net/
  • 65. package main import . "fmt" func main() { s := []int{0, 2, 4, 6, 8} print_slice(func(i int) int { return s[i] }) } func print_slice(s interface{}) { switch s := s.(type) { case func(int) int: for i := 0; i < 5; i++ { Printf("%v: %vn", s(i)) } } } Going Loopy 65 http://slides.games-with-brains.net/
  • 66. package main import . "fmt" func main() { s := []int{0, 2, 4, 6, 8} print_slice(func(i int) int { return s[i] }) } func print_slice(s interface{}) { switch s := s.(type) { case func(int) int: for i := 0; i < 5; i++ { Printf("%v: %vn", s(i)) } } } Going Loopy 66 http://slides.games-with-brains.net/
  • 67. package main import . "fmt" func main() { s := []int{0, 2, 4, 6, 8} print_slice(func(i int) int { return s[i] }) } func print_slice(s interface{}) { switch s := s.(type) { case func(int) int: for i := 0; i < 5; i++ { Printf("%v: %vn", s(i)) } } } Going Loopy 67 http://slides.games-with-brains.net/
  • 68. package main import . "fmt" func main() { s := []int{0, 2, 4, 6, 8} print_slice(func(i int) int { return s[i] }) } func print_slice(s interface{}) { switch s := s.(type) { case func(int) int: for i := 0; i < 5; i++ { Printf("%v: %vn", s(i)) } } } Going Loopy 68 http://slides.games-with-brains.net/
  • 69. package main import . "fmt" func main() { s := []int{0, 2, 4, 6, 8} print_slice(func(i int) int { return s[i] }) } func print_slice(s interface{}) { switch s := s.(type) { case func(int) int: for i := 0; i < 5; i++ { Printf("%v: %vn", s(i)) } } } Going Loopy 69 http://slides.games-with-brains.net/
  • 70. package main import . "fmt" func main() { s := []int{0, 2, 4, 6, 8} print_slice(func(i int) int { return s[i] }) } func print_slice(s interface{}) { switch s := s.(type) { case func(int) int: for i := 0; i < 5; i++ { Printf("%v: %vn", s(i)) } } } Going Loopy 70 http://slides.games-with-brains.net/
  • 71. upon reflection Going Loopy 71 http://slides.games-with-brains.net/
  • 72. package main import . "fmt" func main() { s := []int{0, 2, 4, 6, 8} print_values(s) print_values(func(i int) int { return s[i] * 2 }) } func print_values(s interface{}) { switch s := s.(type) { case func(int) int: for i := 0; i < 5; i++ { Printf("%v: %vn", s(i)) } case []int: for i, v := range s { Printf("%v: %vn", i, v) } } } Going Loopy 72 http://slides.games-with-brains.net/
  • 73. package main import . "fmt" func main() { s := []int{0, 2, 4, 6, 8} print_values(s) print_values(func(i int) int { return s[i] * 2 }) } func print_values(s interface{}) { switch s := s.(type) { case func(int) int: for i := 0; i < 5; i++ { Printf("%v: %vn", s(i)) } case []int: for i, v := range s { Printf("%v: %vn", i, v) } } } Going Loopy 73 http://slides.games-with-brains.net/
  • 74. package main import . "fmt" func main() { s := []int{0, 2, 4, 6, 8} print_values(s) print_values(func(i int) int { return s[i] * 2 }) } func print_values(s interface{}) { switch s := s.(type) { case func(int) int: for i := 0; i < 5; i++ { Printf("%v: %vn", s(i)) } case []int: for i, v := range s { Printf("%v: %vn", i, v) } } } Going Loopy 74 http://slides.games-with-brains.net/
  • 75. package main import . "fmt" func main() { s := []int{0, 2, 4, 6, 8} print_values(s) print_values(func(i int) int { return s[i] * 2 }) } func print_values(s interface{}) { switch s := s.(type) { case func(int) int: for i := 0; i < 5; i++ { Printf("%v: %vn", s(i)) } case []int: for i, v := range s { Printf("%v: %vn", i, v) } } } Going Loopy 75 http://slides.games-with-brains.net/
  • 76. package main import . "fmt" import . "reflect" func main() { s := []int{0, 2, 4, 6, 8} print_values(s) print_values(func(i int) int { return s[i] }) } func print_values(s interface{}) { switch s := ValueOf(s); s.Kind() { case Func: p := []Value{ ValueOf(i) } for i := 0; i < 5; i++ { Printf("%v: %vn", s.Call(p)[0].Interface{}) } case Slice: for i := 0; i < s.Len(); i++ { Printf("%v: %vn", i, s.Index(i)) } } } Going Loopy 76 http://slides.games-with-brains.net/
  • 77. package main import . "fmt" import . "reflect" func main() { s := []int{0, 2, 4, 6, 8} print_values(s) print_values(func(i int) int { return s[i] }) } func print_values(s interface{}) { switch s := ValueOf(s); s.Kind() { case Func: p := []Value{ ValueOf(i) } for i := 0; i < 5; i++ { Printf("%v: %vn", s.Call(p)[0].Interface{}) } case Slice: for i := 0; i < s.Len(); i++ { Printf("%v: %vn", i, s.Index(i)) } } } Going Loopy 77 http://slides.games-with-brains.net/
  • 78. package main import . "fmt" import . "reflect" func main() { s := []int{0, 2, 4, 6, 8} print_values(s) print_values(func(i int) int { return s[i] }) } func print_values(s interface{}) { switch s := ValueOf(s); s.Kind() { case Func: p := []Value{ ValueOf(i) } for i := 0; i < 5; i++ { Printf("%v: %vn", s.Call(p)[0].Interface()) } case Slice: for i := 0; i < s.Len(); i++ { Printf("%v: %vn", i, s.Index(i).Interface()) } } } Going Loopy 78 http://slides.games-with-brains.net/
  • 79. package main import . "fmt" import . "reflect" func main() { s := []int{0, 2, 4, 6, 8} print_values(s) print_values(func(i int) int { return s[i] }) } func print_values(s interface{}) { switch s := ValueOf(s); s.Kind() { case Func: p := []Value{ ValueOf(i) } for i := 0; i < 5; i++ { Printf("%v: %vn", s.Call(p)[0].Interface()) } case Slice: for i := 0; i < s.Len(); i++ { Printf("%v: %vn", i, s.Index(i).Interface()) } } } Going Loopy 79 http://slides.games-with-brains.net/
  • 80. package main import . "fmt" import . "reflect" func main() { s := []int{0, 2, 4, 6, 8} print_values(s) print_values(func(i int) int { return s[i] }) } func print_values(s interface{}) { switch s := ValueOf(s); s.Kind() { case Func: p := []Value{ ValueOf(i) } for i := 0; i < 5; i++ { Printf("%v: %vn", s.Call(p)[0].Interface()) } case Slice: for i := 0; i < s.Len(); i++ { Printf("%v: %vn", i, s.Index(i).Interface()) } } } Going Loopy 80 http://slides.games-with-brains.net/
  • 81. package main import . "fmt" import . "reflect" func main() { s := []int{0, 2, 4, 6, 8} print_values(s) print_values(func(i int) int { return s[i] }) } func print_values(s interface{}) { switch s := ValueOf(s); s.Kind() { case Func: p := []Value{ ValueOf(i) } for i := 0; i < 5; i++ { Printf("%v: %vn", s.Call(p)[0].Interface()) } case Slice: for i := 0; i < s.Len(); i++ { Printf("%v: %vn", i, s.Index(i).Interface()) } } } Going Loopy 81 http://slides.games-with-brains.net/
  • 82. package main import . "fmt" import . "reflect" func main() { s := []int{0, 2, 4, 6, 8} print_values(s) print_values(func(i int) int { return s[i] }) } func print_values(s interface{}) { switch s := ValueOf(s); s.Kind() { case Func: p := []Value{ ValueOf(i) } for i := 0; i < 5; i++ { Printf("%v: %vn", s.Call(p)[0].Interface()) } case Slice: for i := 0; i < s.Len(); i++ { Printf("%v: %vn", i, s.Index(i).Interface()) } } } Going Loopy 82 http://slides.games-with-brains.net/
  • 83. package main import . "fmt" import . "reflect" func main() { s := []int{0, 2, 4, 6, 8} print_values(s) print_values(func(i int) int { return s[i] }) } func print_values(s interface{}) { switch s := ValueOf(s); s.Kind() { case Func: p := []Value{ ValueOf(i) } for i := 0; i < 5; i++ { Printf("%v: %vn", s.Call(p)[0].Interface()) } case Slice: for i := 0; i < s.Len(); i++ { Printf("%v: %vn", i, s.Index(i).Interface()) } } } Going Loopy 83 http://slides.games-with-brains.net/
  • 84. package main import . "fmt" import . "reflect" func main() { s := []int{0, 2, 4, 6, 8} print_values(s) print_values(func(i int) int { return s[i] }) } func print_values(s interface{}) { switch s := ValueOf(s); s.Kind() { case Func: p := []Value{ ValueOf(i) } for i := 0; i < 5; i++ { Printf("%v: %vn", s.Call(p)[0].Interface()) } case Slice: for i := 0; i < s.Len(); i++ { Printf("%v: %vn", i, s.Index(i).Interface()) } } } Going Loopy 84 http://slides.games-with-brains.net/
  • 85. package main import . "fmt" import . "reflect" func main() { s := []int{0, 2, 4, 6, 8} print_values(s) print_values(func(i int) int { return s[i] }) } func print_values(s interface{}) { switch s := ValueOf(s); s.Kind() { case Func: p := []Value{ ValueOf(i) } for i := 0; i < 5; i++ { Printf("%v: %vn", s.Call(p)[0].Interface()) } case Slice: for i := 0; i < s.Len(); i++ { Printf("%v: %vn", i, s.Index(i).Interface()) } } } Going Loopy 85 http://slides.games-with-brains.net/
  • 86. package main import . "fmt" import . "reflect" func main() { s := []int{0, 2, 4, 6, 8} print_values(s) print_values(func(i int) int { return s[i] }) } func print_values(s interface{}) { switch s := ValueOf(s); s.Kind() { case Func: p := []Value{ ValueOf(i) } for i := 0; i < 5; i++ { Printf("%v: %vn", s.Call(p)[0].Interface()) } case Slice: for i := 0; i < s.Len(); i++ { Printf("%v: %vn", i, s.Index(i).Interface()) } } } Going Loopy 86 http://slides.games-with-brains.net/
  • 87. package main import . "fmt" import . "reflect" func main() { s := []int{0, 2, 4, 6, 8} print_values(s) print_values(func(i int) int { return s[i] }) } func print_values(s interface{}) { switch s := ValueOf(s); s.Kind() { case Func: p := []Value{ ValueOf(i) } for i := 0; i < 5; i++ { Printf("%v: %vn", s.Call(p)[0].Interface()) } case Slice: for i := 0; i < s.Len(); i++ { Printf("%v: %vn", i, s.Index(i).Interface()) } } } Going Loopy 87 http://slides.games-with-brains.net/
  • 88. package main import . "fmt" import . "reflect" func main() { s := []int{0, 2, 4, 6, 8} print_values(s) print_values(func(i int) int { return s[i] }) } func print_values(s interface{}) { switch s := ValueOf(s); s.Kind() { case Func: p := []Value{ ValueOf(i) } for i := 0; i < 5; i++ { Printf("%v: %vn", s.Call(p)[0].Interface()) } case Slice: for i := 0; i < s.Len(); i++ { Printf("%v: %vn", i, s.Index(i).Interface()) } } } Going Loopy 88 http://slides.games-with-brains.net/
  • 89. package main import . "fmt" import . "reflect" func main() { s := []int{0, 2, 4, 6, 8} print_values(s) print_values(func(i int) int { return s[i] }) } func print_values(s interface{}) { switch s := ValueOf(s); s.Kind() { case Func: p := []Value{ ValueOf(i) } for i := 0; i < 5; i++ { Printf("%v: %vn", s.Call(p)[0].Interface()) } case Slice: for i := 0; i < s.Len(); i++ { Printf("%v: %vn", i, s.Index(i).Interface()) } } } Going Loopy 89 http://slides.games-with-brains.net/

Editor's Notes

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. \n
  38. \n
  39. \n
  40. \n
  41. \n
  42. \n
  43. \n
  44. \n
  45. \n
  46. \n
  47. \n
  48. \n
  49. \n
  50. \n
  51. \n
  52. \n
  53. \n
  54. \n
  55. \n
  56. \n
  57. \n
  58. \n
  59. \n
  60. \n
  61. \n
  62. \n
  63. \n
  64. \n
  65. \n
  66. \n
  67. \n
  68. \n
  69. \n
  70. \n
  71. \n
  72. \n
  73. \n
  74. \n
  75. \n
  76. \n
  77. \n
  78. \n
  79. \n
  80. \n
  81. \n
  82. \n
  83. \n
  84. \n
  85. \n
  86. \n
  87. \n
  88. \n
  89. \n
  90. \n