In order to learn I'm reading the book An Introduction to Programming in Go so expect a book review soon...
Now...my first impression of Go is that is basically C/C++ without the makeup...meaning...take out some nasty and weird features and you have yourself the Go programming language...
Go is supposed to be compiled, concurrent, imperative and structured.
Anyway...C++ was one of the first languages I ever learned so learning Go feels like going back home for a while...
For sure...the best way to learn a new language is to code something...so again I start by building something simple like the Fibonacci number generator based on Haskell code from another post...
Fibonacci.go |
---|
package main import ( "fmt" "strconv" ) func main() { fmt.Print("Enter a number: ") var num int fmt.Scanf("%d", &num) fmt.Print(fib(num, 0, 1)) } func fib(num int, a int, b int) string{ var result string if a > 0 && num > 1 { result += strconv.Itoa(a+b) + " " + fib(num-1, a+b, a) } else if a == 0 { result = strconv.Itoa(a) + " " + strconv.Itoa(b) + " " + strconv.Itoa(a+b) + " " + fib(num-1, a+b, b) } return result } |
When we run it...we're going to see this -:)
Greetings,
Blag.
Development Culture.
No hay comentarios:
Publicar un comentario