This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Junk Files | |
| *.DS_Store | |
| [Tt]humbs.db | |
| #Visual Studio Files | |
| [Oo]bj | |
| [Bb]in | |
| [Dd]ebug | |
| [Bb]uild/ | |
| *.user |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let object = { | |
| key: { | |
| subkey: 'value', | |
| status: 'STATUS' | |
| } | |
| }; | |
| // compact | |
| Object.assign( {}, object, { key: Object.assign( {}, object.key, { status: 'PENDING' } ) } ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| A Tour of Go: page 44 | |
| http://tour.golang.org/#44 | |
| Exercise: Loops and Functions | |
| As a simple way to play with functions and loops, implement the square root function using Newton's method. | |
| In this case, Newton's method is to approximate Sqrt(x) by picking a starting point z and then repeating: z - (z*z - x) / (2 * z) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import "golang.org/x/tour/pic" | |
| func imageFunc(x, y int) uint8 { | |
| return uint8(x) ^ uint8(y) | |
| } | |
| func Pic(dx, dy int) (image [][]uint8) { | |
| image = make([][]uint8, dy) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "golang.org/x/tour/wc" | |
| "strings" | |
| ) | |
| func WordCount(s string) (count map[string]int) { | |
| words := strings.Fields(s) | |
| count = make(map[string]int) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import "fmt" | |
| // fibonacci is a function that returns | |
| // a function that returns an int. | |
| func fibonacci() func() int { | |
| a, b, n := 0, 1, 0 // a & b are the future values | |
| return func() int { | |
| n, a, b = a, b, a+b |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import "fmt" | |
| type IPAddr [4]byte | |
| // TODO: Add a "String() string" method to IPAddr. | |
| func (ip IPAddr) String() string { | |
| return fmt.Sprintf("%v.%v.%v.%v", ip[0], ip[1], ip[2], ip[3]) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| "math" | |
| ) | |
| const DELTA = 0.00000000001 | |
| const INITIAL_Z = 100.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| "math" | |
| ) | |
| const DELTA = 0.00000000001 | |
| const INITIAL_Z = 100.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import "golang.org/x/tour/reader" | |
| type MyReader struct{} | |
| func (r MyReader) Read(b []byte) (n int, err error) { | |
| b[0] = 'A' | |
| return 1, nil |
OlderNewer