一天熟悉Elixir,練習Koans

最近在exercism.io練習,那個難度稍微大一些,大概要一個月吧,適合於作第二階段提升的練習。git

今天發現一個新的不錯的初學練習方式,一天就能熟悉Elixir的一些基礎,一共18關。github

第一關

好比,第一個簡單地判斷相等:app

defmodule Equalities do
  use Koans

  @intro  """
  Welcome to the Elixir koans.
  Let these be your first humble steps towards learning a new language.

  The path laid in front of you is one of many.
  """

  # Replace ___ with the answer to make the koan pass.
  koan "We shall contemplate truth by testing reality, via equality" do
    assert true == ___
  end

  koan "Not something is the opposite of it" do
    assert !true == ___
  end

  koan "To understand reality, we must compare our expectations against reality" do
    assert 2 == 1 + ___
  end

  koan "Some things may appear different, but be the same" do
    assert 1 == 2 / ___
  end

  koan "Unless they actually are different" do
    assert 3.2 != ___
  end

  koan "Some may be looking for bigger things" do
    assert ___ > 3
  end

  koan "Others are happy with less" do
    assert ___ < 3
  end
end

全部的題目

01_equalities.ex       07_lists.ex            13_functions.ex
02_strings.ex          08_keyword_lists.ex    14_enums.ex
03_sigils.ex           09_maps.ex             15_processes.ex
04_numbers.ex          10_map_sets.ex         16_tasks.ex
05_atoms.ex            11_structs.ex          17_agents.ex
06_tuples.ex           12_pattern_matching.ex 18_protocols.ex

後面4個稍微陌生和難一點。less

運行方式

mix deps.get

mix meditate

不斷練習

能夠反覆練習直到這些成爲直覺。koa

項目學習

這個Koans自己是個不錯的學習項目,能夠經過它學習到一個完整的項目是如何建構的。學習

相關文章
相關標籤/搜索