最近在exercism.io练习,那个难度稍微大一些,大概要一个月吧,适合于做第二阶段提高的练习。
今天发现一个新的不错的,一天就能熟悉Elixir的一些基础,一共18关。
第一关
比如,第一个简单地判断相等:
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 endend
所有的题目
01_equalities.ex 07_lists.ex 13_functions.ex02_strings.ex 08_keyword_lists.ex 14_enums.ex03_sigils.ex 09_maps.ex 15_processes.ex04_numbers.ex 10_map_sets.ex 16_tasks.ex05_atoms.ex 11_structs.ex 17_agents.ex06_tuples.ex 12_pattern_matching.ex 18_protocols.ex
后面4个稍微陌生和难一点。
运行方式
mix deps.getmix meditate
不断练习
可以反复练习直到这些成为直觉。
项目学习
这个Koans本身是个不错的学习项目,可以通过它学习到一个完整的项目是如何建构的。