Learn Functional Programming with Elixir (Pragprog)

by Ulisses Almeida

Elixir’s straightforward syntax and this guided tour give you a clean, simple path to learn modern functional programming techniques. No previous functional programming experience required! This book walks you through the right concepts at the right pace, as you explore immutable values and explicit data transformation, functions, modules, recursive functions, pattern matching, high-order functions, polymorphism, and failure handling, all while avoiding side effects. Don’t board the Elixir train with an imperative mindset! To get the most out of functional languages, you need to think functionally. This book will get you there.

Functional programming offers useful techniques for building maintainable and scalable software that solves today’s difficult problems. The demand for software written in this way is increasing—you don’t want to miss out. In this book, you’ll not only learn Elixir and its features, you’ll also learn the mindset required to program functionally. Elixir’s clean syntax is excellent for exploring the critical skills of using functions and concurrency.

Start with the basic techniques of the functional way: working with immutable data, transforming data in discrete steps, and avoiding side effects. Next, take a deep look at values, expressions, functions, and modules. Then extend your programming with pattern matching and flow control with case, if, cond, and functions. Use recursive functions to create iterations. Work with data types such as lists, tuples, and maps. Improve code reusability and readability with Elixir’s most common high-order functions. Explore how to use lazy computation with streams, design your data, and take advantage of polymorphism with protocols. Combine functions and handle failures in a maintainable way using Elixir features and libraries.

Learn techniques that matter to make code that lives harmoniously with the language.

Don’t forget you can get 35% off the ebook using the code ‘devtalk.com:023:

14 Likes

Looks good - great to see all bases being covered by all these different books :023:

1 Like

As I see the books description and how it is addressed to beginners I wonder what is different from “Programming Elixir”. Does it offer anything more for those who have already read “Programming Elixir”?

I am asking because I am interested in buying this title.

In Programming Elixir by Dave, he will guide you through all Elixir feature showing you some concepts of functional programming, concurrent programming, and testing. The book is for experienced developers. In Learn Functional Programming with Elixir by Ulisses (what me?), it will guide you only though functional concepts and show you Elixir. The book is for beginners, then a lot of examples will be step by step.

A good example is the “recursive functions” subject. In Programming Elixir you’ll have ten pages that describe the recursive function and quickly jump to lists navigation, high order functions, and tail call optimization. In Learn Functional Programming With Elixir, we have entire a chapter with more than 20 pages about recursive functions. You’ll see bounded and unbounded recursion, decrease and conquer, divide and conquer, tail call optimization, and anonymous recursive functions. Then, we have another chapter with more than 20 pages to explain high-order functions, giving you several examples from simples lists operations to lazy computation.

I’ll hope this explanation help you understand the difference between the two books.

11 Likes

So your book teaches functional programming with Elixir as a vehicle. Nice. Looking forward for it. :grin:

Sounds good Ulisses :023:

Please, I need your book ASAP !!!
This is gonna be great :slight_smile: Happy waiting

2 Likes

I need this book now!!!

Well, if it is that urgent Functional Programming in Erlang starts Monday (June 19) and the skills transfer 100% - provided you are willing to put the work in. The course material is available for 5 weeks for free.

My “retrospective” here.

1 Like

beta is finally out :slight_smile:

2 Likes

I just bought it, after receiving the email newsletter. :slight_smile:

The book even link to this thread:

Recursion! :smile:

6 Likes

Nice one @georgeguimaraes :023:

The URL has been updated since mind - though it will still get to this thread. The new URL is:

https://elixirforum.com/t/learn-functional-programming-with-elixir-pragprog/5114

Though if you wanted to, you could use:

https://elixirforum.com/t/learn-functional-programming-with-elixir/5114

:slight_smile:

Blog post outlining the story behind this book :slight_smile:

I’m sure it will be great @ulissesalmeida :023:

1 Like

@AstonJ Thanks!

I need to update the book with thew new URL :laughing:

1 Like

First chapter of this book is currently available as a free download :023:

http://pages.plataformatec.com.br/chapter-thinking-functionally-of-learn-functional-programming-with-elixir

1 Like

I am not sure how to post a question but I started going over the book and I like it a lot. I got stuck with the Enum.each exercise.

I do: apply_tax = fn price -> " Price: #{price} - tax: #{price*0.12}" and when I check it alone it works fine
I then do:Enum.each([12.5, 30.99, 250.49, 18.8], apply_tax ) and it just print :ok:
I also tried: Enum.each([12.5, 30.99, 250.49, 18.8], fn(n) -> apply_tax.(n) end ) with same results please help. Also how do I post regula questions on the forum? I could not find it like onn other forums?

Thank you Amos Madanes

  1. apply_tax returns a string
  2. You are using Enum.each/2 - this suggests you are going through the list for a side effect (rather than generating a new result).

You probably want to show the string on the screen in iex - the piece you are missing is IO.puts/2:

Interactive Elixir (1.5.2) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> apply_tax = fn price -> "Price: #{price} tax: #{price * 0.12}" end
#Function<6.99386804/1 in :erl_eval.expr/5>
iex(2)> Enum.each([12.5, 30.99, 250.49, 18.8], fn(n) -> IO.puts(apply_tax.(n)) end)
Price: 12.5 tax: 1.5
Price: 30.99 tax: 3.7188
Price: 250.49 tax: 30.0588
Price: 18.8 tax: 2.256
:ok
iex(3)> Enum.each([12.5, 30.99, 250.49, 18.8], fn(n) -> n |> apply_tax.() |> IO.puts() end)
Price: 12.5 tax: 1.5
Price: 30.99 tax: 3.7188
Price: 250.49 tax: 30.0588
Price: 18.8 tax: 2.256
:ok
iex(4)> 

FYI:
The book’s forum is actually
https://forums.pragprog.com/forums/440

Though I suspect that you’ll get a much faster response here - as long as you are OK with people answering who haven’t actually read the book.

1 Like

Thank you @peerreynders.

@amadanes You can also download the source code files of the book in https://pragprog.com/titles/cdc-elixir/source_code

There are several folders for each book’s topic. Some of them has answers folder that you can find my suggested answers for the book’s exercises.

The printed version announcement. If you already have bought e-book version, you might have received a coupon discount in your e-mail if you want to purchase the printed version.

https://media.pragprog.com/newsletters/2018-02-28.html

3 Likes