Skip to content

Latest commit

 

History

History
227 lines (147 loc) · 7.75 KB

mapset_drills.livemd

File metadata and controls

227 lines (147 loc) · 7.75 KB

MapSet Drills

Mix.install([
  {:jason, "~> 1.4"},
  {:kino, "~> 0.9", override: true},
  {:youtube, github: "brooklinjazz/youtube"},
  {:hidden_cell, github: "brooklinjazz/hidden_cell"}
])

Navigation

MapSet Drills

Drills help you develop familiarity and muscle memory with syntax through repeated exercises. Unlike usual problems, Drills are not intended to develop problem solving skills, they are purely for developing comfort and speed.

This set of drills is for MapSets follow the instructions for each drill and complete them as quickly as you can.

MapSet.new/2

Use MapSet.new/2 to create a mapset with the integers 1, 2, and 3.

Use MapSet.new/2 to create an empty mapset.

Use MapSet.new/2 to create a mapset with the integers 1 to 10.

Use MapSet.new/2 to create a mapset with the integers 1 to 1000.

Use MapSet.new/2 to create a mapset with the same elements as the list below.

list = [%{}, 2, "3"]

Use MapSet.new/2 to create a mapset with the elements %{key: "value"}, [one: 1], and {1, 2, 3}.

MapSet.put/2

Use MapSet.put/2 to put the element "a" into the existing mapset.

mapset = MapSet.new(["b", "c"])

Use MapSet.new/2 and MapSet.put/2 to put 1 into a MapSet containing the elements 2 and 3.

Use MapSet.put/2 twice with the element 1 on an empty mapset to demonstrate that the MapSet only contains unique values.

MapSet.delete/2

Use MapSet.delete/2 to delete the 1 element from the following mapset.

mapset = MapSet.new([1])

Use MapSet.delete/2 and MapSet.new/2 to create a mapset with elements from 1 to 6 then delete the 6 element.

MapSet.member?/2

Use MapSet.member?/2 to check if 1 is in the following mapset.

mapset = MapSet.new([1, 2, 3])

Use MapSet.new/2 to create a mapset with elements from 1 to 10. Then use MapSet.member?/2 to check if 11 is in the mapset.

Use MapSet.member?/2 to check if %{key: "value"} is in the following mapset.

mapset = MapSet.new([%{key: "value"}])

MapSet.filter/2

Use MapSet.filter/2 to filter the following mapset and make a mapset with only integers.

mapset = MapSet.new(["a", "b", "c", 1, 2, 3])

Use MapSet.new/2 and MapSet.filter/2 to create a mapset with integers from 1 to 10, then filter it to make a mapset with only even numbers.

Use MapSet.filter/2 to filter the following mapset to only include strings containing the letter "a".

MapSet.new(["apple", "orange", "pear", "banana", "cherry", "fruit"])

MapSet.equal?/2

Use MapSet.equal?/2 to check if the following mapset is equal to MapSet.new([1]).

mapset = MapSet.new([1])

Use MapSet.equal?/2 to check if MapSet.new([1, 2, 3, 4, 5]) is equal to MapSet.new(1..5).

Use MapSet.new/2 to create an empty mapset, then MapSet.put/2 to add 1 to the mapset. Then use MapSet.equal?/2 to check if the resulting mapset equals MapSet.new([1])

MapSet.subset?/2

Use MapSet.subset?/2 to check if MapSet.new([2, 3]) is a subset of MapSet.new([1, 2, 3, 4]). The result should be true.

Use MapSet.subset?/2 to check if MapSet.new(["a"]) is a subset of MapSet.new(["a", "b"]).

MapSet.to_list/1

Use MapSet.to_list/1 to convert the following mapset into a list.

mapset = MapSet.new([1, 2, 3])

Commit Your Progress

DockYard Academy now recommends you use the latest Release rather than forking or cloning our repository.

Run git status to ensure there are no undesirable changes. Then run the following in your command line from the curriculum folder to commit your progress.

$ git add .
$ git commit -m "finish MapSet Drills exercise"
$ git push

We're proud to offer our open-source curriculum free of charge for anyone to learn from at their own pace.

We also offer a paid course where you can learn from an instructor alongside a cohort of your peers. We will accept applications for the June-August 2023 cohort soon.

Navigation