Mix.install([
{:youtube, github: "brooklinjazz/youtube"},
{:hidden_cell, github: "brooklinjazz/hidden_cell"},
{:tested_cell, github: "brooklinjazz/tested_cell"},
{:utils, path: "#{__DIR__}/../utils"}
])
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 Streams follow the instructions for each drill and complete them as quickly as you can.
Use Stream.map/2 to double elements in a range from 1..10
, then use Enum.to_list/1 to convert the resulting stream into a list [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]
Use Stream.map/2 and Enum.to_list/1 to sum a list of tuple pairs [{1, 1}, {2, 2}, {3, 3}]
into [2, 4, 6]
.
Use Stream.filter/2 and Enum.to_list/1 to filter even numbers from a range 1..10
to return [2, 4, 6, 8, 10]
.
Use Stream.filter/2 and Enum.to_list/1 to filter numbers greater than 5
from a range 1..10
to return [6, 7, 8, 9, 10]
.
Use Stream.cycle/1 with Enum.take/2 to generate the list [1, 2, 3, 1, 2, 3, 1, 2, 3]
.
Use Stream.cycle/1 with Enum.take/2 to generate the list ["a", "b", "a", "b"]
Use Stream.iterate/2 and Enum.take/2 to generate a list of numbers from 1
to 10
.
Use Stream.iterate/2 and Enum.take/2 to generate a list of negative numbers from 0
to -10
.
Use Stream.iterate/2 and Enum.take/2 to generate a list of 1
to 10
to the power of 2 by multiplying each accumulator by 2. i.e.
Use Stream.unfold/2 and Enum.take/2 to generate a list of 10
cubed numbers. i.e.
Use Stream.unfold/2 and Enum.take/2 to generate a list of 5
integers as strings. ["1", "2", "3", "4", "5"]
.
Use Stream.unfold/2 and Enum.take/2 to generate a list of integers from 1
to 10
divided by 2
.
Use Stream.chunk_every/2 with Enum.to_list/1 to chunk [1, 1, 2, 2, 3, 3]
into [[1, 1], [2, 2], [3, 3], [4, 4]]
Use Stream.chunk_every/2 to chunk [1, 1, 1, 2, 2, 2]
into [[1, 1, 1], [2, 2, 2]]
Use Stream.chunk_every/2 to chunk [1, 2, 2, 1, 4, 4]
into pairs, then use Stream.map/2 to sum the pairs together to make [3, 3, 8]
.
Run the following in your command line from the beta_curriculum folder to track and save your progress in a Git commit.
$ git add .
$ git commit -m "finish stream drills exercise"
Previous | Next |
---|---|
Streams | Lazy Product Filters |