SlideShare ist ein Scribd-Unternehmen logo
1 von 114
Downloaden Sie, um offline zu lesen
going loopy
adventures in iteration with google go
!
!

@feyeleanor

Going Loopy

!1

http://slideshare.net/feyeleanor/
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:
1:
2:
3:
4:

Going Loopy

0	
2	
4	
6	
8

!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/
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

!23

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

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}	
i := 0	
for {	
Printf("%v: %vn", i, s[i])	
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}	
i := 0	
for {	
Printf("%v: %vn", i, s[i])	
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}	
i := 0	
for {	
Printf("%v: %vn", i, s[i])	
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}	
i := 0	
for {	
Printf("%v: %vn", i, s[i])	
i++	
}	
}

Going Loopy

!28

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

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

Going Loopy

!29

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

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

Going Loopy

!30

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

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

Going Loopy

!31

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

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/
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

!36

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

!37

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

!38

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

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([]int{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([]int{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([]int{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/
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

!44

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

!45

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

!46

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

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{}) {	
for i, v := range s.([]int) {	
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{}) {	
for i, v := range s.([]int) {	
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{}) {	
for i, v := range s.([]int) {	
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{}) {	
if s, ok := s.([]int); ok {	
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{}) {	
if s, ok := s.([]int); ok {	
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{}) {	
if s, ok := s.([]int); ok {	
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/
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

!60

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

!61

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

!62

http://slides.games-with-brains.net/
closures

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", i, 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", i, 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", i, 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", i, 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", i, 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", i, 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", i, s(i))	
}	
}	
}

Going Loopy

!70

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", i, s(i))	
}	
}	
}

Going Loopy

!71

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", i, s(i))	
}	
}	
}

Going Loopy

!72

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", i, s(i))	
}	
}	
}

Going Loopy

!73

http://slides.games-with-brains.net/
channels

Going Loopy

!74

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

!
func main() {	
	
c := make(chan int)	
	
go func() {	
	
	
for _, v := range []int{0, 2, 4, 6, 8} {	
	
	
	
c <- v	
	
	
}	
	
	
close(c)	
	
}()	
	
Printf("elements: %vn", print_channel(c))	
}	

!
func print_channel(c chan int) (i int) {	
	
for v := range c {	
	
	
Printf("%v: %vn", i, v)	
	
	
i++	
	
}	
	
return	
}

Going Loopy

!75

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

!
func main() {	
	
c := make(chan int)	
	
go func() {	
	
	
for _, v := range []int{0, 2, 4, 6, 8} {	
	
	
	
c <- v	
	
	
}	
	
	
close(c)	
	
}()	
	
Printf("elements: %vn", print_channel(c))	
}	

!
func print_channel(c chan int) (i int) {	
	
for v := range c {	
	
	
Printf("%v: %vn", i, v)	
	
	
i++	
	
}	
	
return	
}

Going Loopy

!76

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

!
func main() {	
	
c := make(chan int, 16)	
	
go func() {	
	
	
for _, v := range []int{0, 2, 4, 6, 8} {	
	
	
	
c <- v	
	
	
}	
	
	
close(c)	
	
}()	
	
Printf("elements: %vn", print_channel(c))	
}	

!
func print_channel(c chan int) (i int) {	
	
for v := range c {	
	
	
Printf("%v: %vn", i, v)	
	
	
i++	
	
}	
	
return	
}

Going Loopy

!77

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

!
func main() {	
	
c := make(chan int)	
	
go func() {	
	
	
for _, v := range []int{0, 2, 4, 6, 8} {	
	
	
	
c <- v	
	
	
}	
	
	
close(c)	
	
}()	
	
Printf("elements: %vn", print_channel(c))	
}	

!
func print_channel(c chan int) (i int) {	
	
for v := range c {	
	
	
Printf("%v: %vn", i, v)	
	
	
i++	
	
}	
	
return	
}

Going Loopy

!78

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

!
func main() {	
	
c := make(chan int)	
	
go func() {	
	
	
for _, v := range []int{0, 2, 4, 6, 8} {	
	
	
	
c <- v	
	
	
}	
	
	
close(c)	
	
}()	
	
Printf("elements: %vn", print_channel(c))	
}	

!
func print_channel(c chan int) (i int) {	
	
for v := range c {	
	
	
Printf("%v: %vn", i, v)	
	
	
i++	
	
}	
	
return	
}

Going Loopy

!79

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

!
func main() {	
	
c := make(chan int)	
	
go func() {	
	
	
for _, v := range []int{0, 2, 4, 6, 8} {	
	
	
	
c <- v	
	
	
}	
	
	
close(c)	
	
}()	
	
Printf("elements: %vn", print_channel(c))	
}	

!
func print_channel(c chan int) (i int) {	
	
for v := range c {	
	
	
Printf("%v: %vn", i, v)	
	
	
i++	
	
}	
	
return	
}

Going Loopy

!80

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

!
func main() {	
	
c := make(chan int)	
	
go func() {	
	
	
for _, v := range []int{0, 2, 4, 6, 8} {	
	
	
	
c <- v	
	
	
}	
	
	
close(c)	
	
}()	
	
Printf("elements: %vn", print_channel(c))	
}	

!
func print_channel(c chan int) (i int) {	
	
for v := range c {	
	
	
Printf("%v: %vn", i, v)	
	
	
i++	
	
}	
	
return	
}

Going Loopy

!81

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

!
func main() {	
	
c := make(chan int)	
	
go func() {	
	
	
for _, v := range []int{0, 2, 4, 6, 8} {	
	
	
	
c <- v	
	
	
}	
	
	
close(c)	
	
}()	
	
Printf("elements: %vn", print_channel(c))	
}	

!
func print_channel(c chan int) (i int) {	
	
for v := range c {	
	
	
Printf("%v: %vn", i, v)	
	
	
i++	
	
}	
	
return	
}

Going Loopy

!82

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

!
func main() {	
	
c := make(chan int)	
	
go func() {	
	
	
for _, v := range []int{0, 2, 4, 6, 8} {	
	
	
	
c <- v	
	
	
}	
	
	
close(c)	
	
}()	
	
Printf("elements: %vn", print_channel(c))	
}	

!
func print_channel(c chan int) (i int) {	
	
for v := range c {	
	
	
Printf("%v: %vn", i, v)	
	
	
i++	
	
}	
	
return	
}

Going Loopy

!83

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

!
func main() {	
	
c := make(chan int)	
	
go func() {	
	
	
for _, v := range []int{0, 2, 4, 6, 8} {	
	
	
	
c <- v	
	
	
}	
	
	
close(c)	
	
}()	
	
Printf("elements: %vn", print_channel(c))	
}	

!
func print_channel(c chan int) (i int) {	
	
for v := range c {	
	
	
Printf("%v: %vn", i, v)	
	
	
i++	
	
}	
	
return	
}

Going Loopy

!84

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

Going Loopy

!85

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", i, s(i))	
}	
case []int:	
for i, v := range s {	
Printf("%v: %vn", i, v)	
}	
}	
}

Going Loopy

!86

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", i, s(i))	
}	
case []int:	
for i, v := range s {	
Printf("%v: %vn", i, v)	
}	
}	
}

Going Loopy

!87

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", i, s(i))	
}	
case []int:	
for i, v := range s {	
Printf("%v: %vn", i, v)	
}	
}	
}

Going Loopy

!88

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", i, s(i))	
}	
case []int:	
for i, v := range s {	
Printf("%v: %vn", i, v)	
}	
}	
}

Going Loopy

!89

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", i, s.Call(p)[0].Interface{})	
}	
case Slice:	
for i := 0; i < s.Len(); i++ {	
Printf("%v: %vn", i, s.Index(i))	
}	
}	
}
Going Loopy

!90

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", i, s.Call(p)[0].Interface{})	
}	
case Slice:	
for i := 0; i < s.Len(); i++ {	
Printf("%v: %vn", i, s.Index(i))	
}	
}	
}
Going Loopy

!91

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", i, s.Call(p)[0].Interface())	
}	
case Slice:	
for i := 0; i < s.Len(); i++ {	
Printf("%v: %vn", i, s.Index(i).Interface())	
}	
}	
}
Going Loopy

!92

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", i, s.Call(p)[0].Interface())	
}	
case Slice:	
for i := 0; i < s.Len(); i++ {	
Printf("%v: %vn", i, s.Index(i).Interface())	
}	
}	
}
Going Loopy

!93

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", i, s.Call(p)[0].Interface())	
}	
case Slice:	
for i := 0; i < s.Len(); i++ {	
Printf("%v: %vn", i, s.Index(i).Interface())	
}	
}	
}
Going Loopy

!94

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", i, s.Call(p)[0].Interface())	
}	
case Slice:	
for i := 0; i < s.Len(); i++ {	
Printf("%v: %vn", i, s.Index(i).Interface())	
}	
}	
}
Going Loopy

!95

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", i, s.Call(p)[0].Interface())	
}	
case Slice:	
for i := 0; i < s.Len(); i++ {	
Printf("%v: %vn", i, s.Index(i).Interface())	
}	
}	
}
Going Loopy

!96

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", i, s.Call(p)[0].Interface())	
}	
case Slice:	
for i := 0; i < s.Len(); i++ {	
Printf("%v: %vn", i, s.Index(i).Interface())	
}	
}	
}
Going Loopy

!97

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", i, s.Call(p)[0].Interface())	
}	
case Slice:	
for i := 0; i < s.Len(); i++ {	
Printf("%v: %vn", i, s.Index(i).Interface())	
}	
}	
}
Going Loopy

!98

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", i, s.Call(p)[0].Interface())	
}	
case Slice:	
for i := 0; i < s.Len(); i++ {	
Printf("%v: %vn", i, s.Index(i).Interface())	
}	
}	
}
Going Loopy

!99

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", i, s.Call(p)[0].Interface())	
}	
case Slice:	
for i := 0; i < s.Len(); i++ {	
Printf("%v: %vn", i, s.Index(i).Interface())	
}	
}	
}
Going Loopy

!100

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", i, s.Call(p)[0].Interface())	
}	
case Slice:	
for i := 0; i < s.Len(); i++ {	
Printf("%v: %vn", i, s.Index(i).Interface())	
}	
}	
}
Going Loopy

!101

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", i, s.Call(p)[0].Interface())	
}	
case Slice:	
for i := 0; i < s.Len(); i++ {	
Printf("%v: %vn", i, s.Index(i).Interface())	
}	
}	
}
Going Loopy

!102

http://slides.games-with-brains.net/
user-defined type

Going Loopy

!103

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

!
type Iterable interface {	
Each(func(interface{}))	
}	

!
type IterableSlice	[]int	
func (i IterableSlice) Each(f func(interface{})) {	
for _, v := range i {	
f(v)	
}	
}	

!
func main() {	
s := IterableSlice{ 0, 2, 4, 6, 8 }	
i := 0	
s.Each(func(v interface{}) {	
Printf("%v: %vn", i, v)	
i++	
})	
}

Going Loopy

!104

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

!
type Iterable interface {	
Each(func(interface{}))	
}	

!
type IterableSlice	[]int	
func (i IterableSlice) Each(f func(interface{})) {	
for _, v := range i {	
f(v)	
}	
}	

!
func main() {	
s := IterableSlice{ 0, 2, 4, 6, 8 }	
i := 0	
s.Each(func(v interface{}) {	
Printf("%v: %vn", i, v)	
i++	
})	
}

Going Loopy

!105

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

!
type Iterable interface {	
Each(func(interface{}))	
}	

!
type IterableSlice	[]int	
func (i IterableSlice) Each(f func(interface{})) {	
for _, v := range i {	
f(v)	
}	
}	

!
func main() {	
s := IterableSlice{ 0, 2, 4, 6, 8 }	
i := 0	
s.Each(func(v interface{}) {	
Printf("%v: %vn", i, v)	
i++	
})	
}

Going Loopy

!106

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

!
type Iterable interface {	
Each(func(interface{}))	
}	

!
type IterableSlice	[]int	
func (i IterableSlice) Each(f func(interface{})) {	
for _, v := range i {	
f(v)	
}	
}	

!
func main() {	
s := IterableSlice{ 0, 2, 4, 6, 8 }	
i := 0	
s.Each(func(v interface{}) {	
Printf("%v: %vn", i, v)	
i++	
})	
}

Going Loopy

!107

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

!
type Iterable interface {	
Each(func(interface{}))	
}	

!
type IterableSlice	[]int	
func (i IterableSlice) Each(f func(interface{})) {	
for _, v := range i {	
f(v)	
}	
}	

!
func main() {	
s := IterableSlice{ 0, 2, 4, 6, 8 }	
i := 0	
s.Each(func(v interface{}) {	
Printf("%v: %vn", i, v)	
i++	
})	
}

Going Loopy

!108

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

!
type Iterable interface {	
Each(func(interface{}))	
}	

!
type IterableSlice	[]int	
func (i IterableSlice) Each(f func(interface{})) {	
for _, v := range i {	
f(v)	
}	
}	

!
func main() {	
s := IterableSlice{ 0, 2, 4, 6, 8 }	
i := 0	
s.Each(func(v interface{}) {	
Printf("%v: %vn", i, v)	
i++	
})	
}

Going Loopy

!109

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

!
type Iterable interface {	
Each(func(interface{}))	
}	

!
type IterableSlice	[]int	
func (i IterableSlice) Each(f func(interface{})) {	
for _, v := range i {	
f(v)	
}	
}	

!
func main() {	
s := IterableSlice{ 0, 2, 4, 6, 8 }	
i := 0	
s.Each(func(v interface{}) {	
Printf("%v: %vn", i, v)	
i++	
})	
}

Going Loopy

!110

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

!
type Iterable interface {	
Each(func(interface{}))	
}	

!
type IterableSlice	[]int	
func (i IterableSlice) Each(f func(interface{})) {	
for _, v := range i {	
f(v)	
}	
}	

!
func main() {	
s := IterableSlice{ 0, 2, 4, 6, 8 }	
i := 0	
s.Each(func(v interface{}) {	
Printf("%v: %vn", i, v)	
i++	
})	
}

Going Loopy

!111

http://slides.games-with-brains.net/
you now know go

Going Loopy

112

http://slides.games-with-brains.net/
#golang

Going Loopy

113

http://slides.games-with-brains.net/
http://golang.org/

Going Loopy

114

http://slides.games-with-brains.net/

Weitere ähnliche Inhalte

Was ist angesagt?

JavaOne 2010, Rock Star winning presentation on Fugue and Log4JFugue
JavaOne 2010, Rock Star winning presentation on Fugue and Log4JFugueJavaOne 2010, Rock Star winning presentation on Fugue and Log4JFugue
JavaOne 2010, Rock Star winning presentation on Fugue and Log4JFugueBrian Tarbox
 
JFugue, Music, and the Future of Java [JavaOne 2016, CON1851]
JFugue, Music, and the Future of Java [JavaOne 2016, CON1851]JFugue, Music, and the Future of Java [JavaOne 2016, CON1851]
JFugue, Music, and the Future of Java [JavaOne 2016, CON1851]David Koelle
 
Yapc Asia 2008 TMTOWTMS
Yapc Asia 2008 TMTOWTMSYapc Asia 2008 TMTOWTMS
Yapc Asia 2008 TMTOWTMSJeen Lee
 
Alessandro sf 2010
Alessandro sf 2010Alessandro sf 2010
Alessandro sf 2010Puppet
 
Fun with processes - lightning talk
Fun with processes - lightning talkFun with processes - lightning talk
Fun with processes - lightning talkPaweł Dawczak
 
Javasccript MV* frameworks
Javasccript MV* frameworksJavasccript MV* frameworks
Javasccript MV* frameworksKerry Buckley
 
Petunjuk pengisian lhkpn model a
Petunjuk pengisian lhkpn model aPetunjuk pengisian lhkpn model a
Petunjuk pengisian lhkpn model aGolden Saragih
 
Parallel binary search
Parallel binary searchParallel binary search
Parallel binary search승혁 조
 
Using Phing for Fun and Profit
Using Phing for Fun and ProfitUsing Phing for Fun and Profit
Using Phing for Fun and ProfitNicholas Jansma
 
Tercera parte parte del Cuaderno de Ingles
Tercera parte parte del Cuaderno de InglesTercera parte parte del Cuaderno de Ingles
Tercera parte parte del Cuaderno de InglesRicardo Aguilar
 
ใบงานเรื่องการคอมไพล์โปรแกรม
ใบงานเรื่องการคอมไพล์โปรแกรมใบงานเรื่องการคอมไพล์โปรแกรม
ใบงานเรื่องการคอมไพล์โปรแกรมธงชัย พาศรี
 
Awesomely descriptive JavaScript with monads
Awesomely descriptive JavaScript with monadsAwesomely descriptive JavaScript with monads
Awesomely descriptive JavaScript with monadsMichal Nowak
 
Amazon Alexa Development
Amazon Alexa DevelopmentAmazon Alexa Development
Amazon Alexa DevelopmentRyan Chung
 
PyData Paris 2015 - Track 3.2 Serge Guelton et Pierrick Brunet
PyData Paris 2015 - Track 3.2 Serge Guelton et Pierrick Brunet PyData Paris 2015 - Track 3.2 Serge Guelton et Pierrick Brunet
PyData Paris 2015 - Track 3.2 Serge Guelton et Pierrick Brunet Pôle Systematic Paris-Region
 
SecureSocial - Authentication for Play Framework
SecureSocial - Authentication for Play FrameworkSecureSocial - Authentication for Play Framework
SecureSocial - Authentication for Play Frameworkjaliss
 

Was ist angesagt? (18)

JavaOne 2010, Rock Star winning presentation on Fugue and Log4JFugue
JavaOne 2010, Rock Star winning presentation on Fugue and Log4JFugueJavaOne 2010, Rock Star winning presentation on Fugue and Log4JFugue
JavaOne 2010, Rock Star winning presentation on Fugue and Log4JFugue
 
FPBrno 2018-05-22: Benchmarking in elixir
FPBrno 2018-05-22: Benchmarking in elixirFPBrno 2018-05-22: Benchmarking in elixir
FPBrno 2018-05-22: Benchmarking in elixir
 
JFugue, Music, and the Future of Java [JavaOne 2016, CON1851]
JFugue, Music, and the Future of Java [JavaOne 2016, CON1851]JFugue, Music, and the Future of Java [JavaOne 2016, CON1851]
JFugue, Music, and the Future of Java [JavaOne 2016, CON1851]
 
Yapc Asia 2008 TMTOWTMS
Yapc Asia 2008 TMTOWTMSYapc Asia 2008 TMTOWTMS
Yapc Asia 2008 TMTOWTMS
 
Alessandro sf 2010
Alessandro sf 2010Alessandro sf 2010
Alessandro sf 2010
 
Fun with processes - lightning talk
Fun with processes - lightning talkFun with processes - lightning talk
Fun with processes - lightning talk
 
Javasccript MV* frameworks
Javasccript MV* frameworksJavasccript MV* frameworks
Javasccript MV* frameworks
 
Petunjuk pengisian lhkpn model a
Petunjuk pengisian lhkpn model aPetunjuk pengisian lhkpn model a
Petunjuk pengisian lhkpn model a
 
FFT
FFTFFT
FFT
 
Parallel binary search
Parallel binary searchParallel binary search
Parallel binary search
 
Using Phing for Fun and Profit
Using Phing for Fun and ProfitUsing Phing for Fun and Profit
Using Phing for Fun and Profit
 
Tercera parte parte del Cuaderno de Ingles
Tercera parte parte del Cuaderno de InglesTercera parte parte del Cuaderno de Ingles
Tercera parte parte del Cuaderno de Ingles
 
ใบงานเรื่องการคอมไพล์โปรแกรม
ใบงานเรื่องการคอมไพล์โปรแกรมใบงานเรื่องการคอมไพล์โปรแกรม
ใบงานเรื่องการคอมไพล์โปรแกรม
 
Awesomely descriptive JavaScript with monads
Awesomely descriptive JavaScript with monadsAwesomely descriptive JavaScript with monads
Awesomely descriptive JavaScript with monads
 
Groovy kind of test
Groovy kind of testGroovy kind of test
Groovy kind of test
 
Amazon Alexa Development
Amazon Alexa DevelopmentAmazon Alexa Development
Amazon Alexa Development
 
PyData Paris 2015 - Track 3.2 Serge Guelton et Pierrick Brunet
PyData Paris 2015 - Track 3.2 Serge Guelton et Pierrick Brunet PyData Paris 2015 - Track 3.2 Serge Guelton et Pierrick Brunet
PyData Paris 2015 - Track 3.2 Serge Guelton et Pierrick Brunet
 
SecureSocial - Authentication for Play Framework
SecureSocial - Authentication for Play FrameworkSecureSocial - Authentication for Play Framework
SecureSocial - Authentication for Play Framework
 

Andere mochten auch

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
 
GoLightly - a customisable virtual machine written in Go
GoLightly - a customisable virtual machine written in GoGoLightly - a customisable virtual machine written in Go
GoLightly - a customisable virtual machine written in GoEleanor 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
 
Implementing Virtual Machines in Go & C
Implementing Virtual Machines in Go & CImplementing Virtual Machines in Go & C
Implementing Virtual Machines in Go & CEleanor McHugh
 
Going Loopy: Adventures in Iteration with Go
Going Loopy: Adventures in Iteration with GoGoing Loopy: Adventures in Iteration with Go
Going Loopy: Adventures in Iteration with GoEleanor 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
 
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
 

Andere mochten auch (7)

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
 
GoLightly - a customisable virtual machine written in Go
GoLightly - a customisable virtual machine written in GoGoLightly - a customisable virtual machine written in Go
GoLightly - a customisable virtual machine written in Go
 
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
 
Implementing Virtual Machines in Go & C
Implementing Virtual Machines in Go & CImplementing Virtual Machines in Go & C
Implementing Virtual Machines in Go & C
 
Going Loopy: Adventures in Iteration with Go
Going Loopy: Adventures in Iteration with GoGoing Loopy: Adventures in Iteration with Go
Going Loopy: Adventures in Iteration with Go
 
Implementing Virtual Machines in Ruby & C
Implementing Virtual Machines in Ruby & CImplementing Virtual Machines in Ruby & C
Implementing Virtual Machines in Ruby & C
 
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
 

Ähnlich wie going loopy - adventures in iteration with google go

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
 
An introduction to functional programming with go
An introduction to functional programming with goAn introduction to functional programming with go
An introduction to functional programming with goEleanor McHugh
 
10〜30分で何となく分かるGo
10〜30分で何となく分かるGo10〜30分で何となく分かるGo
10〜30分で何となく分かるGoMoriyoshi Koizumi
 
Go Containers
Go ContainersGo Containers
Go Containersjgrahamc
 
Crunching data with go: Tips, tricks, use-cases
Crunching data with go: Tips, tricks, use-casesCrunching data with go: Tips, tricks, use-cases
Crunching data with go: Tips, tricks, use-casesSergii Khomenko
 
Python Peculiarities
Python PeculiaritiesPython Peculiarities
Python Peculiaritiesnoamt
 
Are we ready to Go?
Are we ready to Go?Are we ready to Go?
Are we ready to Go?Adam Dudczak
 
Testing CLI tools with Go
Testing CLI tools with GoTesting CLI tools with Go
Testing CLI tools with GoRicardo Gerardi
 
JDD 2016 - Philippe Charrière - Golo, The Tiny Language That Gives Super Powers
JDD 2016 - Philippe Charrière -  Golo, The Tiny Language That Gives Super PowersJDD 2016 - Philippe Charrière -  Golo, The Tiny Language That Gives Super Powers
JDD 2016 - Philippe Charrière - Golo, The Tiny Language That Gives Super PowersPROIDEA
 
Advanced Debugging Using Java Bytecodes
Advanced Debugging Using Java BytecodesAdvanced Debugging Using Java Bytecodes
Advanced Debugging Using Java BytecodesGanesh Samarthyam
 
Python-GTK
Python-GTKPython-GTK
Python-GTKYuren Ju
 
Generics, Reflection, and Efficient Collections
Generics, Reflection, and Efficient CollectionsGenerics, Reflection, and Efficient Collections
Generics, Reflection, and Efficient CollectionsEleanor McHugh
 
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
 
Something about Golang
Something about GolangSomething about Golang
Something about GolangAnton Arhipov
 
PyGame Tutorial | PyGame Python Tutorial For Beginners | Python Certification...
PyGame Tutorial | PyGame Python Tutorial For Beginners | Python Certification...PyGame Tutorial | PyGame Python Tutorial For Beginners | Python Certification...
PyGame Tutorial | PyGame Python Tutorial For Beginners | Python Certification...Edureka!
 

Ähnlich wie going loopy - adventures in iteration with google go (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...
 
An introduction to functional programming with go
An introduction to functional programming with goAn introduction to functional programming with go
An introduction to functional programming with go
 
10〜30分で何となく分かるGo
10〜30分で何となく分かるGo10〜30分で何となく分かるGo
10〜30分で何となく分かるGo
 
Go Containers
Go ContainersGo Containers
Go Containers
 
Go Containers
Go ContainersGo Containers
Go Containers
 
Crunching data with go: Tips, tricks, use-cases
Crunching data with go: Tips, tricks, use-casesCrunching data with go: Tips, tricks, use-cases
Crunching data with go: Tips, tricks, use-cases
 
Python Peculiarities
Python PeculiaritiesPython Peculiarities
Python Peculiarities
 
Are we ready to Go?
Are we ready to Go?Are we ready to Go?
Are we ready to Go?
 
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
 
Testing CLI tools with Go
Testing CLI tools with GoTesting CLI tools with Go
Testing CLI tools with Go
 
JDD 2016 - Philippe Charrière - Golo, The Tiny Language That Gives Super Powers
JDD 2016 - Philippe Charrière -  Golo, The Tiny Language That Gives Super PowersJDD 2016 - Philippe Charrière -  Golo, The Tiny Language That Gives Super Powers
JDD 2016 - Philippe Charrière - Golo, The Tiny Language That Gives Super Powers
 
python codes
python codespython codes
python codes
 
Advanced Debugging Using Java Bytecodes
Advanced Debugging Using Java BytecodesAdvanced Debugging Using Java Bytecodes
Advanced Debugging Using Java Bytecodes
 
Python-GTK
Python-GTKPython-GTK
Python-GTK
 
Generics, Reflection, and Efficient Collections
Generics, Reflection, and Efficient CollectionsGenerics, Reflection, and Efficient Collections
Generics, Reflection, and Efficient Collections
 
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
 
Something about Golang
Something about GolangSomething about Golang
Something about Golang
 
PyGame Tutorial | PyGame Python Tutorial For Beginners | Python Certification...
PyGame Tutorial | PyGame Python Tutorial For Beginners | Python Certification...PyGame Tutorial | PyGame Python Tutorial For Beginners | Python Certification...
PyGame Tutorial | PyGame Python Tutorial For Beginners | Python Certification...
 
Awt components
Awt componentsAwt components
Awt components
 

Mehr von 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
 
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
 
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
 
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
 
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
 
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
 
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
 
Anonymity, trust, accountability
Anonymity, trust, accountabilityAnonymity, trust, accountability
Anonymity, trust, accountabilityEleanor 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
 

Mehr von 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
 
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]
 
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
 
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
 
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]
 
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
 
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
 
Anonymity, trust, accountability
Anonymity, trust, accountabilityAnonymity, trust, accountability
Anonymity, trust, accountability
 
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
 
Go a crash course
Go   a crash courseGo   a crash course
Go a crash course
 

Kürzlich hochgeladen

Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 

Kürzlich hochgeladen (20)

Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 

going loopy - adventures in iteration with google go

  • 1. going loopy adventures in iteration with google go ! ! @feyeleanor Going Loopy !1 http://slideshare.net/feyeleanor/
  • 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: 1: 2: 3: 4: Going Loopy 0 2 4 6 8 !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. 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 !23 http://slides.games-with-brains.net/
  • 24. the infinite loop 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} i := 0 for { Printf("%v: %vn", i, s[i]) 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} i := 0 for { Printf("%v: %vn", i, s[i]) 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} i := 0 for { Printf("%v: %vn", i, s[i]) 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} i := 0 for { Printf("%v: %vn", i, s[i]) i++ } } Going Loopy !28 http://slides.games-with-brains.net/
  • 29. package main import . "fmt" ! func main() { defer func() { recover() }() s := []int{0, 2, 4, 6, 8} i := 0 for { Printf("%v: %vn", i, s[i]) i++ } } Going Loopy !29 http://slides.games-with-brains.net/
  • 30. package main import . "fmt" ! func main() { defer func() { recover() }() s := []int{0, 2, 4, 6, 8} i := 0 for { Printf("%v: %vn", i, s[i]) i++ } } Going Loopy !30 http://slides.games-with-brains.net/
  • 31. package main import . "fmt" ! func main() { defer func() { recover() }() s := []int{0, 2, 4, 6, 8} i := 0 for i := 0; ; i++ { Printf("%v: %vn", i, s[i]) i++ } } Going Loopy !31 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. 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 !36 http://slides.games-with-brains.net/
  • 37. 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 !37 http://slides.games-with-brains.net/
  • 38. 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 !38 http://slides.games-with-brains.net/
  • 39. a functional interlude 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([]int{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([]int{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([]int{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. 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 !44 http://slides.games-with-brains.net/
  • 45. 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 !45 http://slides.games-with-brains.net/
  • 46. 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 !46 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{}) { for i, v := range s.([]int) { 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{}) { for i, v := range s.([]int) { 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{}) { for i, v := range s.([]int) { 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{}) { if s, ok := s.([]int); ok { 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{}) { if s, ok := s.([]int); ok { 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{}) { if s, ok := s.([]int); ok { 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. 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 !60 http://slides.games-with-brains.net/
  • 61. 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 !61 http://slides.games-with-brains.net/
  • 62. 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 !62 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", i, 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", i, 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", i, 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", i, 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", i, 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", i, 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", i, s(i)) } } } Going Loopy !70 http://slides.games-with-brains.net/
  • 71. 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", i, s(i)) } } } Going Loopy !71 http://slides.games-with-brains.net/
  • 72. 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", i, s(i)) } } } Going Loopy !72 http://slides.games-with-brains.net/
  • 73. 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", i, s(i)) } } } Going Loopy !73 http://slides.games-with-brains.net/
  • 75. package main import . "fmt" ! func main() { c := make(chan int) go func() { for _, v := range []int{0, 2, 4, 6, 8} { c <- v } close(c) }() Printf("elements: %vn", print_channel(c)) } ! func print_channel(c chan int) (i int) { for v := range c { Printf("%v: %vn", i, v) i++ } return } Going Loopy !75 http://slides.games-with-brains.net/
  • 76. package main import . "fmt" ! func main() { c := make(chan int) go func() { for _, v := range []int{0, 2, 4, 6, 8} { c <- v } close(c) }() Printf("elements: %vn", print_channel(c)) } ! func print_channel(c chan int) (i int) { for v := range c { Printf("%v: %vn", i, v) i++ } return } Going Loopy !76 http://slides.games-with-brains.net/
  • 77. package main import . "fmt" ! func main() { c := make(chan int, 16) go func() { for _, v := range []int{0, 2, 4, 6, 8} { c <- v } close(c) }() Printf("elements: %vn", print_channel(c)) } ! func print_channel(c chan int) (i int) { for v := range c { Printf("%v: %vn", i, v) i++ } return } Going Loopy !77 http://slides.games-with-brains.net/
  • 78. package main import . "fmt" ! func main() { c := make(chan int) go func() { for _, v := range []int{0, 2, 4, 6, 8} { c <- v } close(c) }() Printf("elements: %vn", print_channel(c)) } ! func print_channel(c chan int) (i int) { for v := range c { Printf("%v: %vn", i, v) i++ } return } Going Loopy !78 http://slides.games-with-brains.net/
  • 79. package main import . "fmt" ! func main() { c := make(chan int) go func() { for _, v := range []int{0, 2, 4, 6, 8} { c <- v } close(c) }() Printf("elements: %vn", print_channel(c)) } ! func print_channel(c chan int) (i int) { for v := range c { Printf("%v: %vn", i, v) i++ } return } Going Loopy !79 http://slides.games-with-brains.net/
  • 80. package main import . "fmt" ! func main() { c := make(chan int) go func() { for _, v := range []int{0, 2, 4, 6, 8} { c <- v } close(c) }() Printf("elements: %vn", print_channel(c)) } ! func print_channel(c chan int) (i int) { for v := range c { Printf("%v: %vn", i, v) i++ } return } Going Loopy !80 http://slides.games-with-brains.net/
  • 81. package main import . "fmt" ! func main() { c := make(chan int) go func() { for _, v := range []int{0, 2, 4, 6, 8} { c <- v } close(c) }() Printf("elements: %vn", print_channel(c)) } ! func print_channel(c chan int) (i int) { for v := range c { Printf("%v: %vn", i, v) i++ } return } Going Loopy !81 http://slides.games-with-brains.net/
  • 82. package main import . "fmt" ! func main() { c := make(chan int) go func() { for _, v := range []int{0, 2, 4, 6, 8} { c <- v } close(c) }() Printf("elements: %vn", print_channel(c)) } ! func print_channel(c chan int) (i int) { for v := range c { Printf("%v: %vn", i, v) i++ } return } Going Loopy !82 http://slides.games-with-brains.net/
  • 83. package main import . "fmt" ! func main() { c := make(chan int) go func() { for _, v := range []int{0, 2, 4, 6, 8} { c <- v } close(c) }() Printf("elements: %vn", print_channel(c)) } ! func print_channel(c chan int) (i int) { for v := range c { Printf("%v: %vn", i, v) i++ } return } Going Loopy !83 http://slides.games-with-brains.net/
  • 84. package main import . "fmt" ! func main() { c := make(chan int) go func() { for _, v := range []int{0, 2, 4, 6, 8} { c <- v } close(c) }() Printf("elements: %vn", print_channel(c)) } ! func print_channel(c chan int) (i int) { for v := range c { Printf("%v: %vn", i, v) i++ } return } Going Loopy !84 http://slides.games-with-brains.net/
  • 86. 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", i, s(i)) } case []int: for i, v := range s { Printf("%v: %vn", i, v) } } } Going Loopy !86 http://slides.games-with-brains.net/
  • 87. 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", i, s(i)) } case []int: for i, v := range s { Printf("%v: %vn", i, v) } } } Going Loopy !87 http://slides.games-with-brains.net/
  • 88. 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", i, s(i)) } case []int: for i, v := range s { Printf("%v: %vn", i, v) } } } Going Loopy !88 http://slides.games-with-brains.net/
  • 89. 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", i, s(i)) } case []int: for i, v := range s { Printf("%v: %vn", i, v) } } } Going Loopy !89 http://slides.games-with-brains.net/
  • 90. 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", i, s.Call(p)[0].Interface{}) } case Slice: for i := 0; i < s.Len(); i++ { Printf("%v: %vn", i, s.Index(i)) } } } Going Loopy !90 http://slides.games-with-brains.net/
  • 91. 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", i, s.Call(p)[0].Interface{}) } case Slice: for i := 0; i < s.Len(); i++ { Printf("%v: %vn", i, s.Index(i)) } } } Going Loopy !91 http://slides.games-with-brains.net/
  • 92. 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", i, s.Call(p)[0].Interface()) } case Slice: for i := 0; i < s.Len(); i++ { Printf("%v: %vn", i, s.Index(i).Interface()) } } } Going Loopy !92 http://slides.games-with-brains.net/
  • 93. 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", i, s.Call(p)[0].Interface()) } case Slice: for i := 0; i < s.Len(); i++ { Printf("%v: %vn", i, s.Index(i).Interface()) } } } Going Loopy !93 http://slides.games-with-brains.net/
  • 94. 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", i, s.Call(p)[0].Interface()) } case Slice: for i := 0; i < s.Len(); i++ { Printf("%v: %vn", i, s.Index(i).Interface()) } } } Going Loopy !94 http://slides.games-with-brains.net/
  • 95. 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", i, s.Call(p)[0].Interface()) } case Slice: for i := 0; i < s.Len(); i++ { Printf("%v: %vn", i, s.Index(i).Interface()) } } } Going Loopy !95 http://slides.games-with-brains.net/
  • 96. 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", i, s.Call(p)[0].Interface()) } case Slice: for i := 0; i < s.Len(); i++ { Printf("%v: %vn", i, s.Index(i).Interface()) } } } Going Loopy !96 http://slides.games-with-brains.net/
  • 97. 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", i, s.Call(p)[0].Interface()) } case Slice: for i := 0; i < s.Len(); i++ { Printf("%v: %vn", i, s.Index(i).Interface()) } } } Going Loopy !97 http://slides.games-with-brains.net/
  • 98. 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", i, s.Call(p)[0].Interface()) } case Slice: for i := 0; i < s.Len(); i++ { Printf("%v: %vn", i, s.Index(i).Interface()) } } } Going Loopy !98 http://slides.games-with-brains.net/
  • 99. 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", i, s.Call(p)[0].Interface()) } case Slice: for i := 0; i < s.Len(); i++ { Printf("%v: %vn", i, s.Index(i).Interface()) } } } Going Loopy !99 http://slides.games-with-brains.net/
  • 100. 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", i, s.Call(p)[0].Interface()) } case Slice: for i := 0; i < s.Len(); i++ { Printf("%v: %vn", i, s.Index(i).Interface()) } } } Going Loopy !100 http://slides.games-with-brains.net/
  • 101. 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", i, s.Call(p)[0].Interface()) } case Slice: for i := 0; i < s.Len(); i++ { Printf("%v: %vn", i, s.Index(i).Interface()) } } } Going Loopy !101 http://slides.games-with-brains.net/
  • 102. 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", i, s.Call(p)[0].Interface()) } case Slice: for i := 0; i < s.Len(); i++ { Printf("%v: %vn", i, s.Index(i).Interface()) } } } Going Loopy !102 http://slides.games-with-brains.net/
  • 104. package main import . "fmt" ! type Iterable interface { Each(func(interface{})) } ! type IterableSlice []int func (i IterableSlice) Each(f func(interface{})) { for _, v := range i { f(v) } } ! func main() { s := IterableSlice{ 0, 2, 4, 6, 8 } i := 0 s.Each(func(v interface{}) { Printf("%v: %vn", i, v) i++ }) } Going Loopy !104 http://slides.games-with-brains.net/
  • 105. package main import . "fmt" ! type Iterable interface { Each(func(interface{})) } ! type IterableSlice []int func (i IterableSlice) Each(f func(interface{})) { for _, v := range i { f(v) } } ! func main() { s := IterableSlice{ 0, 2, 4, 6, 8 } i := 0 s.Each(func(v interface{}) { Printf("%v: %vn", i, v) i++ }) } Going Loopy !105 http://slides.games-with-brains.net/
  • 106. package main import . "fmt" ! type Iterable interface { Each(func(interface{})) } ! type IterableSlice []int func (i IterableSlice) Each(f func(interface{})) { for _, v := range i { f(v) } } ! func main() { s := IterableSlice{ 0, 2, 4, 6, 8 } i := 0 s.Each(func(v interface{}) { Printf("%v: %vn", i, v) i++ }) } Going Loopy !106 http://slides.games-with-brains.net/
  • 107. package main import . "fmt" ! type Iterable interface { Each(func(interface{})) } ! type IterableSlice []int func (i IterableSlice) Each(f func(interface{})) { for _, v := range i { f(v) } } ! func main() { s := IterableSlice{ 0, 2, 4, 6, 8 } i := 0 s.Each(func(v interface{}) { Printf("%v: %vn", i, v) i++ }) } Going Loopy !107 http://slides.games-with-brains.net/
  • 108. package main import . "fmt" ! type Iterable interface { Each(func(interface{})) } ! type IterableSlice []int func (i IterableSlice) Each(f func(interface{})) { for _, v := range i { f(v) } } ! func main() { s := IterableSlice{ 0, 2, 4, 6, 8 } i := 0 s.Each(func(v interface{}) { Printf("%v: %vn", i, v) i++ }) } Going Loopy !108 http://slides.games-with-brains.net/
  • 109. package main import . "fmt" ! type Iterable interface { Each(func(interface{})) } ! type IterableSlice []int func (i IterableSlice) Each(f func(interface{})) { for _, v := range i { f(v) } } ! func main() { s := IterableSlice{ 0, 2, 4, 6, 8 } i := 0 s.Each(func(v interface{}) { Printf("%v: %vn", i, v) i++ }) } Going Loopy !109 http://slides.games-with-brains.net/
  • 110. package main import . "fmt" ! type Iterable interface { Each(func(interface{})) } ! type IterableSlice []int func (i IterableSlice) Each(f func(interface{})) { for _, v := range i { f(v) } } ! func main() { s := IterableSlice{ 0, 2, 4, 6, 8 } i := 0 s.Each(func(v interface{}) { Printf("%v: %vn", i, v) i++ }) } Going Loopy !110 http://slides.games-with-brains.net/
  • 111. package main import . "fmt" ! type Iterable interface { Each(func(interface{})) } ! type IterableSlice []int func (i IterableSlice) Each(f func(interface{})) { for _, v := range i { f(v) } } ! func main() { s := IterableSlice{ 0, 2, 4, 6, 8 } i := 0 s.Each(func(v interface{}) { Printf("%v: %vn", i, v) i++ }) } Going Loopy !111 http://slides.games-with-brains.net/
  • 112. you now know go Going Loopy 112 http://slides.games-with-brains.net/