l3x/learn-fp-go

Imperative vs Declarative

Closed this issue · 3 comments

Hi sorry just started reading. Just a minor question
In the introduction part that deals compares Imperative and declarative programming.
Is the code for declarative supposed to work or just an illustration how it is done in other functional programming languages as seen in go code ? Because I have gotten an error when trying to run in particular to the slice having a contains method

Here is the code

cars := []string{"Accord", "IS250", "Blazer" }
fmt.Printf("Found? %v", cars.contains("Blazer"))

meanwhile the 'imperative' code has worked fine.
Thanks

l3x commented

Ah, yes. The content in the book you have will soon be revised to match the code.

If you go to the fp-go/1-functional-fundamentals/ch01-pure-fp/01_oop directory and type this: . init && go-run

... you should get this output: Found &{Model:Highlander}

Two things to note: 1) I created a init script that handles dependency management (the vendor directory) and simplifies the process of building and running the applications in each chapter. 2) The code is good. The version of the book you have is not always up-to-date with the code, but a revised copy will be out soon.

I initially did not get a chance to proof the chapters before the book was published. The discrepancies are mainly at the beginning of the book. The publisher should send you the revised copy (no charge) when it's ready.

Lex

Thank you for your response. I would be keeping tabs on the update. The concepts on the rest of the book are very practical

l3x commented

My pleasure. Happy to help. Speaking of helping... Assuming you like my book, I'd appreciate a short comment/rating here: https://www.amazon.com/Learning-Functional-Programming-Lex-Sheehan-ebook/dp/B0725B8MYW

Thanks!
Lex