By Developers, For Developers

Historical errata for Learn Functional Programming with Elixir

PDF PgPaper PgTypeDescriptionFixed onComments
3TYPO

Foundatons instead of Foundations

2017-08-27
6TYPO

Capitalization error under the Transforming Values section near the bottom of the page. 4th line in the first paragraph of the aforementioned section:

“FOr example, the code below”

2017-08-27
7TYPO

Malformed sentence, poor grammar after the JavaScript example.

“The what that needs to be done is mixed and obfuscated by boilerplate actions and mutating values.”

Perhaps this should read as “What needs to be done is mixed and obfuscated by…”?

2017-08-27
6TYPO

First full paragraph after the source code example.

“You’ll learn the details of how create Elixir functions in … ” => “You’ll learn the details of how to create Elixir functions in …”

2017-08-27
6SUGGEST

First full paragraph after the source code example.

I find the use of contractions in formal writing to be a distraction. So, rather than saying “operations and data aren’t attached to each other.” say “operations and data are not attached to each other.”

2017-08-27
6TYPO

Same sentence as the typo reported by James T. Perreault.

Original sentence:

FOr example, the code below takes a text like “the dark tower”, and transforms in a title, “The Dark Tower”.

There’s a typo at the end of the sentence. Suggested fix:

For example, the code below takes a text like “the dark tower” and transforms it into a title, “The Dark Tower”.

2017-08-27
133ERROR

list = [1, 2, 3, 4]
Enum.take(list, –1) # => [4]
list [1]

  1. => [1, 2, 3, 1]
    The latter output should be: [1, 2, 3, 4, 1]
2017-08-27
8SUGGEST

The last sentence before the section “Wrapping Up” is a perfect place to use an em dash!

Rather than:

The important aspects of the task, the parts that matter, are explicit.

You can hang with the cool literary types and say:

The important aspects of the task—-the parts that matter—-are explicit.

Just replace the “—-” with a proper em dash!

2017-08-27
133SUGGEST

“Elixir has smart data structures that reuse values in memory, making every copy very efficient.” Is it Elixir or Erlang? Any possibility for elaboration?

2017-08-27Elixir has data structures that takes advantages of the Erlang VM smart memory operations. \n \nIt's a Elixir semantic that's the Erlang VM implement. Ther's a thin line between them, is not wrong say Elixir has it.
155TYPO

The Ruby line of code: “pusts basket.items.inspect” -> “puts basket.items.inspect”

2017-08-27
2717SUGGEST

“When we say in programming that functions are first-class citizens, we mean that they don’t get special treatment; rather, they are like any other value.”
For me, it means something more like “natively supported, no need to do something to have it”.

2017-08-27If we take a look at Wikipedia, "first-class citizens" is about being used like any other value. It's not about have native support or not for functions. \n \n> "a first-class citizen (also type, object, entity, or value) in a given programming language is an entity which supports all the operations generally available to other entities" \n \nsource: https://en.wikipedia.org/wiki/First-class_citizen
28-3018-20SUGGEST

Could you please elaborate whether closures and free variables is a good practice? Why not change free variables to passing them as function arguments (assuming no shadowing of course)?

2017-09-21I think it's a good topic for a forum discussion. What do you think in open a topic about it in https://forums.pragprog.com/forums/440 ?
10TYPO

Text surrounded by double quotes is a value of the String.t type.

Can be String without .t?

2017-08-27It can't. According with Elixir documentation, if we want to reference the UTF-8 texts, we should reference them as String.t. \n \n> "If you want to refer to the “string” type (the one operated on by functions in the String module), use String.t/0 type instead" \n \nsource: https://hexdocs.pm/elixir/typespecs.html#notes
4232SUGGEST

(CompileError) a binary field without size is only allowed at the end of a binary pattern
Having Elixir 1.5.1 on my machine, the error is:

(CompileError) a binary field without size is only allowed at the end of a binary pattern and never allowed in binary generators

2017-08-27
4535TYPO

The value of the last element of the list (:f) is missing from the figure.

2017-08-27
21ERROR

Elixir code example results cited on Page 21 shows the replacement of the 4th list element. Instead, the result should be an expansion of the original list by appending number 1.

list = [1,2,3,4]
Enum.take(list, –1)

list [1]

  1. => [1,2,3,4,1] incorrect. command should append 1 to end of list
2017-08-27
24TYPO

Ruby example contains a typo:

pusts basket.items.inspect
should be
puts basket.items.inspect

2017-08-27
26TYPO

FOr example, the code below takes a text like “the dark tower”, and transforms in a title, “The Dark Tower”.

should be

For example, the code below takes a text like “the dark tower”, and transforms in a title, “The Dark Tower”.

2017-08-27
7363TYPO

“merge” function should appear as “_merge” everywhere, both the text and the code.

2017-08-27
133ERROR

list [1]

  1. => [1, 2, 3, 1]

The correct result is

  1. => [1, 2, 3, 4, 1]
2017-08-27
166TYPO

In the first paragrapg of Transforming Values, line 4:

FOr example (second letter is capitalized)

2017-08-27
166TYPO

“FOr example, the code below takes a text like ”the dark tower“, and transforms in a title, ”The Dark Tower“.”

2017-09-21
13ERROR

on “Working with Immutable Data” section

the code example actually misleads the reader.

list = [1, 2, 3, 4]
Enum.take(list, –1) (it doesn’t actually take anything from the previous defined list

  1. => [4]
    list [1]
  2. => [1, 2, 3, 1] (the result of that is actually [1, 2, 3, 4, 1])
    IO.inspect list
  3. => [1, 2, 3, 4]

maybe i didn’t understand well, but I felt it was misleading my reading.

2017-09-21
3ERROR

list = [1, 2, 3, 4]
list [1]

  1. => [1, 2, 3, 4, 1]
2017-09-21
110101TYPO

In the last complete sentence on the page, there is an extra word “it” after the word “features”. It should say, " You can consult other useful features in the Mix official documentation."

2017-10-12
114104SUGGEST

The latest version of Elixir, 1.5.1, generates a different version of test/dungeon_crawl_test.exs. Instead of:

test “the truth” do
assert 1 + 1 == 2
end

we now get:

test “greets the world” do
assert DungeonCrawl.hello() == :world
end

You may want to update the version of test/dungeon_crawl_test.exs in the book to match what is currently generated.

2017-10-13
115106TYPO

In the first paragraph of the section titled “Create the Start Task”, fourth sentence, there is a repeated word “that” before the word “starts”. It should say, “Let’s build a task that starts our game.”

2017-10-12
18TYPO

The first example in ‘Functions as First-Class Citizens’ seems incorrect. The total_price anonymous function returns price + fee, but the fee functions also return price + fee resulting in a total_price of 2005 and 2120 instead of the 1005 and 1120 shown in the book.

2017-10-12
15TYPO

In the second paragraph under the heading ‘Creating Anonymous Functions’. The sentence “First, we need to identity the things that change in the messages.” identity should be changed to identify.

2017-10-12
68TYPO

“It takes a lot of memoryto do repetitive tasks.”

2017-10-12
65TYPO

I can’t find “_merge/2” in the book’s pdf file. May be this is an mistake and you mean “merge/2”.
The same is on page 76 :
“Extra challenge: write the tail recursive version of Sort._merge/2.”

2017-10-12
10SUGGEST

In the ‘Running the Code’ section, ‘elixir -v’ displays 1.5.1, but ‘iex’ displays 1.4.4.
To avoid the confusion, I think it is better to ‘elixir -v’ and ‘iex’ should display same version in this context.

2017-10-13
119ERROR

After implementing the function crawl(rooms) you can use it with mix start only if you modify the main.ex file like this:

def start_game do
welcome_message()
prompt(“Press enter to continue”)
hero_choice()
DungeonCrawl.Room.all #mod
|> crawl #mod
end

2017-10-24
62-6353-54ERROR

The check_age.exs script has a minor error. It doesn’t have a condition where the age of 18 is accepted. The condition should probably look more like this:

result = cond do
age < 13 -> “kid” # up to twelve
age < 20 -> “teen” # from thirteen to nineteen
age > 19 -> “adult” # from twenty onwards
end

2017-10-24
7869TYPO

iex> scream = fn word -> String.upcase(“{word}!!!”) end

Missing the hash for the string interpolation, should be:
iex> scream = fn word -> String.upcase(“#{word}!!!”) end

2017-10-24
55TYPO

> We can create how many functions clauses we need.

We can create as many functions clauses as we need.

2017-10-31
29ERROR

> iex> total_price = fn price, fee -> price + fee.(price) end
> The function total_price receives two arguments; one is a number that will rep- resent the price. The tax parameter expects a function.

No `tax` parameter exists.

2017-10-31
28TYPO

> Special forms are basic building blocks that can’t not be overridden by the developer.

Double negative.

2017-10-31
40ERROR

Code example does not match text. Text mentions “tax” however code example has a “fee” parameter

2017-11-05
p20.6TYPO

Building Programs with Functions
Using Values Explicitly
misspelled? repetead

2018-02-23It's not misspelled.
44SUGGEST

Change the year in the code example from 2016 to 2017 (or 2018, if the book will be official released next year).

2018-01-25
6TYPO

“While in Ruby example the operation…” should probably be “While in the Ruby example, the operation…” or
“While in Ruby, the operation…”

2018-01-25
16TYPO

In the example: total_damage_bonus = strengh_score * magic_enchancement
the word “strength” is misspelled

2018-01-25
16TYPO

The title of the box “Naming Things Is a Hard” should probably be either “Naming Things is Hard” (without the “a”) or “Naming Things is a Hard Problem”

2018-01-25
24TYPO

last paragraph: “oficial” should be “official”

2018-01-25
25TYPO

3rd para “but you don’t need to worry about it now, you’ll see how to build a proper project”

use semi-colon instead of a comma

2018-01-25
25TYPO

3rd para “Then, after create the file”
Should probably be either
“Then, after we create the file”
or “Then, after you create the file”

2018-01-25
84ERROR

The “do:” part of the second clause for factorial_of in tr_factorial.ex should be:

defp factorial_of(n, acc) when n > 0, do: factorial_of(n - 1, n * acc)

instead of:

defp factorial_of(n, acc) when n > 0, do: _of(n - 1, n * acc)

2018-01-25
103TYPO

In the sentence before the higher_order_functions.ex code, the word “taht” should be “that” and the word “compose” should be “composes”. It should say, “First, let’s create a function that composes functions …”

2018-01-25
22ERROR

mobi version does not correctly display the graphics for the scope example on page 22 and 23 pdf version numbers or loc 904 through 929 mobi.

The boxes are all blank with no text but different shading.

2018-02-27
72ERROR

The following code compiles with error.
defp factorial_of(n,acc) when n > 0, do: _of(n - 1, n * acc)
Compilation error in file tr_factorial.ex

(CompileError) tr_factorial.ex:8: undefined function _of/2
(stdlib) lists.erl:1338: :lists.foreach/2
(stdlib) erl_eval.erl:670: :erl_eval.do_apply/6

A fix could be :
defp factorial_of(n,acc) when n > 0, do: factorial_of(n - 1, n * acc)

2018-01-25
92TYPO

Instead of “First, let’s create a function taht compose” we should have “First, let’s create a function THAT compose”

2018-01-25
112ERROR

def run(pieces) do
\tpieces
\t|> Enum.map(&add_thread/1)
\t|> Enum.map(&add_head/1)
\t|> Enum.each(&output/1)
end

defp add_thread(piece) do
\tProcess.sleep(50)
\tpiece <> “—”
end

defp add_head(piece) do
\tProcess.sleep(100)
\t“o” <> piece
end

defp output(screw) do
\tIO.inspect(screw)
end

Errors in compiling:

iex(1)> c(“screws_factory.ex”)

Compilation error in file screws_factory.ex

(ArgumentError) cannot invoke def/2 outside module
(elixir) lib/kernel.ex:4615: Kernel.assert_module_scope/3
(elixir) lib/kernel.ex:3566: Kernel.define/4
(elixir) expanding macro: Kernel.def/2
screws_factory.ex:1: (file)

(CompileError) compile error
(iex) lib/iex/helpers.ex:178: IEx.Helpers.c/2

2018-01-25
29SUGGEST

In Functions as First-Class Citizens, the explanation is “The tax parameter expects a function.”
But tax parameter is not in the example code:
iex> total_price = fn price, fee -> price + fee.(price) end

The explanation should be “The fee parameter…” or example code should be the following:
iex> total_price = fn price, tax -> price + tax.(price) end

2018-01-25
62TYPO

Two missing “n”s in a sentence. “prepeding” and “appeding” The full sentence is below.

Note, using this syntax we’re preped-
ing an element in a list, that is many times faster than appeding with <> operator.

2018-01-25
5TYPO

In the paragraph beginning with “The MySet class doesn’t allow repetead values…” The word ‘repeated’ is misspelled

2018-02-23
13TYPO

There is a footnote with a link to the Elixir documentation that points to the “master” docs and not the “stable.”

From:

hexdocs.pm/elixir/master/operators.html

To:

hexdocs.pm/elixir/operators.html

2018-02-23
22ERROR

This sentence: " That’s why the anonymous function can’t see the make_answer
variable: it was defined after the function-creation expression"

Should be: " That’s why the anonymous function can’t see the redefined answer
variable: it was redefined after the function-creation expression"

make_answer is the function, answer is the variable that was redefined to 0. The function can’t see the redefinition to 0 because it was done after the function was defined. Is my understanding correct?

3ERROR

Book’s example:
list = [1, 2, 3, 4]
List.delete_at(list, –1)

  1. => [4]

My iex result:
iex(1)> list = [1, 2, 3, 4]
[1, 2, 3, 4]
iex(2)> List.delete_at(list, –1)
[1, 2, 3]

My Elixir version:
Elixir 1.6.3 (compiled with OTP 19)

31TYPO

In the last exercise of the “Your Turn” section there is the following sentence:

The boxes can’t have fewer matchstick that they can hold; they must be full.

Seems like it should be “fewer matchsticks than they can hold”.

15TYPO

“The || is kind of or operator that works with Booleans and values.” should be “The || is a kind of or operator…”. The sentence from the book is missing “a” before kind.

18TYPO

Example for Creating Anonymous Functions says “we’ll build messages to say hello to Ana, John, and the world.” The first example lists Mary instead of Ana. Subsequent examples use Ana. Mary should be replaced with Ana.

78TYPO

In the first paragraph of the page, the second and third sentences read as “When we create recursive functions, we call functions that have the same name of the function that we’re creating, and it has been working great. The compiler knows how to use that function-name reference to call the function that we creating.”

It seems like the the third sentence should end with “created” instead of “creating”.

27ERROR

While compile a source code file in a name space please write
iex > c(“ecommerce/checkout.ex”)
instead of
iex > c(“checkout.ex”)

source code tree of working directory at this point of descrition is:

checkout.ex
- ecommerce / checkout.ex

61TYPO

When we " look at how it works step by step:" (how the function “sum” works) there is a typo - unnecessary square brackets there is
sum([10, 5, 15]]) =

Current function description there is
sum([10, 5, 15]) =

169SUGGEST

In the second exercise in the last function definition “def filter_items([item | rest], magic: filter_magic) do” while compiling the source code we get a warning:

“warning: variable ”item" is unused (if the variable is not meant to be used, pre
fix it with an underscore)
general_store.ex:36
"
Fixing it is very simple. Just add an underscore to the “_item”

101SUGGEST

Compiler suggestion:
warning: Stream.chunk/2 is deprecated. Use Stream.chunk_every/2 instead

172TYPO

The order of the exercises are confused. The answers to exercise 2 and 3 are mixed up.

107SUGGEST

After launching the comand ‘mix test’, the result looked different (in more detail):

Compiling 1 file (.ex)
Generated dungeon_crawl app
..

Finished in 0.04 seconds
1 doctest, 1 test, 0 failures

109SUGGEST

After adding a task to a project and run new task by ‘mix start’ command the output message should be:
Compiling 1 file (.ex)
Generated dungeon_crawl app
Hello, World!
This output inform that the project was recompiled.

When you run task again the output will be:
Hello, World!
The compiled task just run.

63TYPO

The same typo has in a paper page number 64.

Book Example:
recursion/lib/enchanter_shop.ex

@enchanter_name “Edwin”

def enchant_for_sale([]), do: []
def enchant_for_sale([item | incoming_items]) do
new_item = %{
title: “#{@enchanter_name}’s #{item.title}”,
price: item.price * 3,
magic: true
}
[new_item | enchant_for_sale(incoming_items)]
end

iex> c(“enchanter_shop.ex”)
iex> EnchanterShop.enchant_for_sale(EnchanterShop.test_data)
[%{magic: true, price: 150, title: “Edwin’s Longsword”},
%{magic: true, price: 180, title: “Edwin’s Healing Potion”},
%{magic: true, price: 30, title: “Edwin’s Rope”},
%{magic: true, price: 300, title: “Edwin’s Dragon’s Spear”}]

My Suggestion:

So, no module has ever been defined. It must defined a defmodule EnchanterShop.

Categories: