diff --git a/content/reviews/books/introducing-erlang.md b/content/reviews/books/introducing-erlang.md index c2c7dac..65cbf35 100644 --- a/content/reviews/books/introducing-erlang.md +++ b/content/reviews/books/introducing-erlang.md @@ -1,6 +1,7 @@ +++ title = "Introducing Erlang: Getting Started in Functional Programming - Simon St. Laurent" date = 2020-08-05 +updated = 2020-10-26 [taxonomies] tags = ["books", "reviews", "simon st laurent", "erlang", "it", @@ -34,3 +35,46 @@ learning path, the book says _nothing_ about those things. For seeing how the language looks like, it's a good book. For something more _real_... far away from it. + +## Highlights + +> go to the command line and type erl + +*Note*: `erl` is the Erlang Shell. + +> 3> 2#1010111. + +*Note*: Binary notation. + +> 4> 16#cafe + +*Note*: Hex notation. + +> FallVelocity = fun(Distance) -> math:sqrt(2 * 9.8 * Distance) end. + +*Note*: `fun` creates an anonymous function; it is then associated with the +name `FallVelocity` (all variables need to start with an upcase letter). + +> -module(drop).
+> -export([fall_velocity/1, mps_to_mph/1, mps_to_kph/1]).

+> fall_velocity(Distance) -> math:sqrt(2 * 9.8 * Distance).
+> mps_to_mph(Mps) -> 2.23693629 * Mps.
+> mps_to_kph(Mps) -> 3.6 * Mps. + +> -module(combined).
+> -export([height_to_mph/1]).
+> -import(drop, [fall_velocity/1]).
+> -import(convert, [mps_to_mph/1]).
+> height_to_mph(Meters) -> mps_to_mph(fall_velocity(Meters)). + +> In Erlang, greater-than-or-equal-to is written as >=, and +> less-than-or-equal-to as =<. Don’t make them look like arrows. + +> try
+> math:sqrt(2 * Gravity * Distance)
+> catch
+> error:Error -> {error, Error} end. + +> Creating a map requires a different syntax presenting keys and values:
+> 1> Planemos = #{ earth => 9.8, moon => 1.6, mars => 3.71 }.
+> #{earth => 9.8,mars => 3.71,moon => 1.6}