cs326:daily4

**Part 1.** Work through the `Control Structures`

lesson at Elixirschool.com. Make a transcript file as before. Only try those examples that use the `iex>`

prompt.

**Part 2.**

For the functions developed in this part, use pattern matching on the parameters when you can. Write a script with alpha tests

- Develop a set of functions to determine if a quadratic equation has 2, 1, or 0 solutions.The equation has 0 solutions if it is
*degenerate*that is, if the first coefficient is 0. The equation has 1 solution if the equation has*repeated roots*(when the discriminant is 0). The equation has 2 solutions otherwise, but notice that the solutions are complex if the discriminant is negative. Example functions:`degenerate`

- takes a number, the first coefficient`quad_solutions`

- takes a tuple containing three numbers, the coefficients`discriminant`

- this you already have

- You can combine the built-in data structures as in, for example, a list of maps:
[%{:artist => "howling wolf"}, %{:artist => "three dog night"}]

Write a function that takes a list such as the above and a map and returns a new list with the new

`playlist_entry`

added to the*end*. - In your script file, create a list containing at least 5 songs in a playlist. Each song is a map (call it
`playlist_entry`

, for example) with keys`:artist`

,`:title`

, and`:duration`

. Have at least 2 songs by the same artist. Test your function with this as the starting point.

We'll be building more interesting examples with this notion of a playlist in future assignments.

- Hint: You can put any expression that can be converted to a string inside the #{…} used inside the string we send to 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}"

cs326/daily4.txt · Last modified: 2018/02/16 15:17 by scarl