Reading: Who uses Erlang/Elixir and why?.
Part 1. For two of the companies listed in the reading, explain the most important reason they choose to use BEAM languages. Support your reason with details from the article.
For the functions developed in this assignment, try pattern matching on the parameters where it makes sense. Write alpha tests directly into your script (call it daily4.exs
).
Part 2. Define a module Daily4.Quadratic
containing these functions:
degenerate
- takes a number, the first coefficientquad_solutions
- takes a tuple containing three numbers, the coefficientsdiscriminant
- this you already have
Part 3. Define a module Daily4.Playlist
(this can go in the same file) containing these functions:
[%{:artist => "howling wolf"}, %{:artist => "three dog night"}]
Write a function that takes a list of maps and a single map, and returns a new list with the single map added to the end.
songs
; call it playlist
. Each song
is a map as in the previous question but with three keys :artist
, :title
, and :duration
. In this list, have at least 2 songs by the same artist. Test your function with this list and several others of your own devising. IO.puts
(or any string anywhere). This is called string interpolation. Example:lst = ["one", 2 , "three"] IO.puts "Here's the first entry: #{hd lst}"
Note on testing: it is important to test edge cases. For lists, that includes the empty list, a singleton list, and a list with several items. So along with playlist
described above, include at least 3 more tests.
We'll be building more interesting examples with this notion of a playlist in future assignments.