Powered by AppSignal & Oban Pro
Would you like to see your link here? Contact us

Book Search

exercises/deprecated_book_search.livemd

Book Search

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

Navigation

Home Report An Issue Animal GeneratorBuilt-In Elixir Modules

Book Search

You are building an application for searching books.

Represent each book as a Book struct with title key. Then create a Book.search/2 function to filter a list of Book structs by their title as documented in the Book module below.

defmodule Book do
  @moduledoc """
  Documentation for `Book`.

  ## Examples

    iex> %Book{title: "My Book Title"}
    %Book{title: "My Book Title"}
  """

  @doc """
  Search a list of Book structs. Search should match any book that includes the
  filter in their title.

  ## Examples

  Include books that exactly match the search query.

    iex> book1 = %Book{title: "A"}
    iex> book2 = %Book{title: "B"}
    iex> book3 = %Book{title: "C"}
    iex> Book.search([book1, book2, book3], "A")
    [%Book{title: "A"}]

  Include books that partially match the search query.

    iex> Book.search([%Book{title: "ABC"}], "A")
    [%Book{title: "ABC"}]

    iex> Book.search([%Book{title: "BAC"}], "A")
    [%Book{title: "BAC"}]

  Search should be case insensitive.

    iex> Book.search([%Book{title: "ABC"}], "a")
    [%Book{title: "ABC"}]
  """
  def search(books, query) do
  end
end

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 Book Search 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

Home Report An Issue Animal GeneratorBuilt-In Elixir Modules