Created
April 27, 2016 11:51
-
-
Save brweber2/340a2f53c00a7d38c527313c0642398a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
characters = [ | |
%{name: "Han", type: :human, rebel: true, weight: 185}, | |
%{name: "Jabba", type: :hutt, rebel: false, weight: 2200}, | |
%{name: "Chewie", type: :wookie, rebel: true, weight: 350}, | |
%{name: "r2d2", type: :droid, rebel: true, weight: 250}, | |
%{name: "Luke", type: :human, rebel: true, weight: 140}, | |
%{name: "Boba Fett", type: :human, rebel: false, weight: 175}, | |
] | |
# Note that there is more than one correct answer for all of these! | |
# Question 1 - In one line of code, set a variable called wookie_name to the name of the wookie character | |
[_, _, %{name: wookie_name, type: :wookie}, _, _, _] = characters | |
# Question 2 - In one line of code, set a variable called 'weight' to how much Han weighs | |
[%{weight: weight} | _t] = characters | |
##### Advanced (we haven't covered all of this yet, you'll likely need to read documentation) | |
# Question 3 - In one line of code, create a list of the names of the humans | |
for %{type: :human, name: name} <- characters, do: name | |
# Question 4 - In one line of code, create a list of all the humans that weigh less than 180 lbs. | |
for c = %{type: :human} <- characters, c.weight < 180, into: [], do: c |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment