├── 2nd-edition ├── ch04 │ ├── ex1-case │ │ ├── xbuild │ │ │ └── dev │ │ │ │ ├── lib │ │ │ │ └── drop │ │ │ │ │ ├── .compile.xref │ │ │ │ │ ├── .compile.elixir │ │ │ │ │ ├── .compile.elixir_scm │ │ │ │ │ └── ebin │ │ │ │ │ └── drop.app │ │ │ │ └── consolidated │ │ │ │ └── .compile.protocols │ │ ├── test │ │ │ ├── test_helper.exs │ │ │ └── drop_test.exs │ │ ├── lib │ │ │ └── drop.ex │ │ ├── .gitignore │ │ └── README.md │ ├── ex5-if │ │ ├── test │ │ │ ├── test_helper.exs │ │ │ └── drop_test.exs │ │ ├── lib │ │ │ └── drop.ex │ │ ├── .gitignore │ │ └── README.md │ ├── ex2-case │ │ ├── test │ │ │ ├── test_helper.exs │ │ │ └── drop_test.exs │ │ ├── lib │ │ │ └── drop.ex │ │ ├── .gitignore │ │ └── README.md │ ├── ex3-case │ │ ├── test │ │ │ ├── test_helper.exs │ │ │ └── drop_test.exs │ │ ├── lib │ │ │ └── drop.ex │ │ ├── .gitignore │ │ └── README.md │ ├── ex4-cond │ │ ├── test │ │ │ ├── test_helper.exs │ │ │ └── drop_test.exs │ │ ├── .gitignore │ │ └── README.md │ ├── ex6-broken │ │ ├── test │ │ │ ├── test_helper.exs │ │ │ └── broken_test.exs │ │ ├── lib │ │ │ └── broken.ex │ │ └── .gitignore │ ├── ex8-countup │ │ ├── test │ │ │ ├── test_helper.exs │ │ │ └── count_test.exs │ │ ├── lib │ │ │ └── count.ex │ │ └── .gitignore │ ├── ex7-countdown │ │ ├── test │ │ │ ├── test_helper.exs │ │ │ └── count_test.exs │ │ ├── lib │ │ │ └── count.ex │ │ └── .gitignore │ ├── ex11-factorial-up │ │ ├── test │ │ │ ├── test_helper.exs │ │ │ └── fact_test.exs │ │ ├── lib │ │ │ └── fact.ex │ │ ├── .gitignore │ │ └── README.md │ ├── ex9-factorial-down │ │ ├── test │ │ │ ├── test_helper.exs │ │ │ └── fact_test.exs │ │ ├── lib │ │ │ └── fact.ex │ │ └── .gitignore │ ├── ex10-factorial-down-instrumented │ │ ├── test │ │ │ ├── test_helper.exs │ │ │ └── fact_test.exs │ │ ├── lib │ │ │ └── fact.ex │ │ └── .gitignore │ └── ex11-factorial-down-tail-recursive │ │ ├── test │ │ ├── test_helper.exs │ │ └── fact_test.exs │ │ ├── lib │ │ └── fact.ex │ │ └── .gitignore ├── ch09 │ ├── testor │ │ ├── test │ │ │ ├── test_helper.exs │ │ │ └── mph_drop_test.exs │ │ └── .gitignore │ ├── ex1-simple │ │ ├── test │ │ │ ├── test_helper.exs │ │ │ └── bounce_test.exs │ │ ├── lib │ │ │ └── bounce.ex │ │ └── .gitignore │ ├── ex3-counter │ │ ├── test │ │ │ ├── test_helper.exs │ │ │ └── bounce_test.exs │ │ ├── lib │ │ │ └── bounce.ex │ │ └── .gitignore │ ├── ex4-state │ │ ├── test │ │ │ ├── test_helper.exs │ │ │ └── bounce_test.exs │ │ ├── lib │ │ │ └── bounce.ex │ │ └── .gitignore │ ├── ex6-talking │ │ ├── test │ │ │ ├── test_helper.exs │ │ │ └── drop_test.exs │ │ ├── .gitignore │ │ └── README.md │ ├── ex8-linking │ │ ├── test │ │ │ ├── test_helper.exs │ │ │ └── mph_drop_test.exs │ │ └── .gitignore │ ├── ex10-resilient │ │ ├── test │ │ │ ├── test_helper.exs │ │ │ └── mph_drop_test.exs │ │ └── .gitignore │ ├── ex2-recursion │ │ ├── test │ │ │ ├── test_helper.exs │ │ │ └── bounce_test.exs │ │ ├── lib │ │ │ └── bounce.ex │ │ └── .gitignore │ ├── ex5-division │ │ ├── test │ │ │ ├── test_helper.exs │ │ │ └── bounce_test.exs │ │ ├── lib │ │ │ └── bounce.ex │ │ └── .gitignore │ ├── ex7-talkingProcs │ │ ├── test │ │ │ ├── test_helper.exs │ │ │ └── mph_drop_test.exs │ │ └── .gitignore │ └── ex9-trapping │ │ ├── test │ │ ├── test_helper.exs │ │ └── mph_drop_test.exs │ │ └── .gitignore ├── ch11 │ ├── zorko │ │ ├── test │ │ │ ├── test_helper.exs │ │ │ └── zorko_test.exs │ │ ├── lib │ │ │ └── zorko.ex │ │ ├── .gitignore │ │ └── README.md │ ├── dia_test │ │ ├── test │ │ │ ├── test_helper.exs │ │ │ └── dia_test_test.exs │ │ ├── lib │ │ │ └── dia_test.ex │ │ └── .gitignore │ ├── ex1-guards │ │ ├── test │ │ │ ├── test_helper.exs │ │ │ └── drop_test.exs │ │ ├── .gitignore │ │ └── README.md │ ├── ex2-specs │ │ ├── test │ │ │ ├── test_helper.exs │ │ │ └── specs_test.exs │ │ └── .gitignore │ ├── ex3-specs │ │ ├── test │ │ │ ├── test_helper.exs │ │ │ └── new_type_test.exs │ │ └── .gitignore │ ├── ex4-testing │ │ ├── test │ │ │ ├── test_helper.exs │ │ │ └── drop_test.exs │ │ ├── lib │ │ │ ├── drop_bad.ex │ │ │ └── drop_good.ee │ │ └── .gitignore │ ├── ex5-setup │ │ ├── test │ │ │ └── test_helper.exs │ │ ├── lib │ │ │ └── drop.ex │ │ └── .gitignore │ ├── ex6-doctest │ │ ├── test │ │ │ ├── test_helper.exs │ │ │ └── drop_test.exs │ │ └── .gitignore │ └── ex4a-testing │ │ ├── test │ │ ├── test_helper.exs │ │ ├── drop2_test.exs │ │ ├── drop3_test.exs │ │ ├── drop_test.exs │ │ └── drop4_test.exs │ │ ├── lib │ │ └── drop.ex │ │ ├── .gitignore │ │ └── README.md ├── ch02 │ ├── ex1-drop │ │ ├── test │ │ │ ├── test_helper.exs │ │ │ └── drop_test.exs │ │ ├── lib │ │ │ └── drop.ex │ │ ├── .gitignore │ │ └── README.md │ ├── ex2-split │ │ ├── test │ │ │ ├── test_helper.exs │ │ │ └── drop_test.exs │ │ ├── lib │ │ │ ├── drop.ex │ │ │ └── convert.ex │ │ ├── .gitignore │ │ └── README.md │ ├── ex4a-pipe │ │ ├── test │ │ │ ├── test_helper.exs │ │ │ └── combined_test.exs │ │ ├── lib │ │ │ ├── drop.ex │ │ │ ├── combined.ex │ │ │ └── convert.ex │ │ └── .gitignore │ ├── ex5-import │ │ ├── test │ │ │ ├── test_helper.exs │ │ │ └── combined_test.exs │ │ ├── lib │ │ │ ├── drop.ex │ │ │ ├── combined.ex │ │ │ └── convert.ex │ │ └── .gitignore │ ├── ex7-docs │ │ ├── test │ │ │ ├── test_helper.exs │ │ │ └── combined_test.exs │ │ ├── lib │ │ │ ├── drop.ex │ │ │ ├── convert.ex │ │ │ └── combined.ex │ │ └── .gitignore │ ├── ex10-doc-specs │ │ ├── test │ │ │ ├── test_helper.exs │ │ │ └── combined_test.exs │ │ ├── lib │ │ │ ├── combined.ex │ │ │ ├── convert.ex │ │ │ └── drop.ex │ │ └── .gitignore │ ├── ex11-doc-module │ │ ├── test │ │ │ ├── test_helper.exs │ │ │ └── combined_test.exs │ │ ├── lib │ │ │ ├── combined.ex │ │ │ └── convert.ex │ │ └── .gitignore │ ├── ex3-combined │ │ ├── test │ │ │ ├── test_helper.exs │ │ │ └── combined_test.exs │ │ ├── lib │ │ │ ├── drop.ex │ │ │ ├── combined.ex │ │ │ └── convert.ex │ │ └── .gitignore │ ├── ex4-combined │ │ ├── test │ │ │ ├── test_helper.exs │ │ │ └── combined_test.exs │ │ ├── lib │ │ │ ├── drop.ex │ │ │ ├── combined.ex │ │ │ └── convert.ex │ │ └── .gitignore │ ├── ex6-defaults │ │ ├── test │ │ │ ├── test_helper.exs │ │ │ └── drop_test.exs │ │ ├── lib │ │ │ └── drop.ex │ │ ├── .gitignore │ │ └── README.md │ ├── ex8-doc-function │ │ ├── test │ │ │ ├── test_helper.exs │ │ │ └── combined_test.exs │ │ ├── lib │ │ │ ├── combined.ex │ │ │ ├── convert.ex │ │ │ └── drop.ex │ │ └── .gitignore │ └── ex5-import-erlang │ │ ├── test │ │ ├── test_helper.exs │ │ └── drop_test.exs │ │ ├── lib │ │ └── drop.ex │ │ ├── .gitignore │ │ └── README.md ├── ch03 │ ├── ex1-atoms │ │ ├── test │ │ │ ├── test_helper.exs │ │ │ └── drop_test.exs │ │ ├── lib │ │ │ └── drop.ex │ │ ├── .gitignore │ │ └── README.md │ ├── ex2-guards │ │ ├── test │ │ │ ├── test_helper.exs │ │ │ └── drop_test.exs │ │ ├── lib │ │ │ └── drop.ex │ │ ├── .gitignore │ │ └── README.md │ ├── ex4-tuples │ │ ├── test │ │ │ ├── test_helper.exs │ │ │ └── drop_test.exs │ │ ├── lib │ │ │ └── drop.ex │ │ ├── .gitignore │ │ └── README.md │ ├── absolute-value-1 │ │ ├── test │ │ │ ├── test_helper.exs │ │ │ └── math_demo_test.exs │ │ ├── lib │ │ │ └── math_demo.ex │ │ └── .gitignore │ ├── absolute-value-2 │ │ ├── test │ │ │ ├── test_helper.exs │ │ │ └── math_demo_test.exs │ │ ├── lib │ │ │ └── math_demo.ex │ │ └── .gitignore │ ├── ex3-underscore │ │ ├── test │ │ │ ├── test_helper.exs │ │ │ └── drop_test.exs │ │ ├── lib │ │ │ ├── drop2.ex │ │ │ └── drop.ex │ │ ├── .gitignore │ │ └── README.md │ └── ex5-tuplesMore │ │ ├── test │ │ ├── test_helper.exs │ │ └── drop_test.exs │ │ ├── lib │ │ └── drop.ex │ │ ├── .gitignore │ │ └── README.md ├── ch05 │ ├── ex1-ask │ │ ├── test │ │ │ ├── test_helper.exs │ │ │ └── ask_test.exs │ │ ├── lib │ │ │ └── ask.ex │ │ ├── .gitignore │ │ └── README.md │ ├── ex2-ask │ │ ├── test │ │ │ ├── test_helper.exs │ │ │ └── ask_test.exs │ │ ├── lib │ │ │ └── drop.ex │ │ ├── .gitignore │ │ └── README.md │ └── ex3-ask │ │ ├── test │ │ ├── test_helper.exs │ │ └── ask_test.exs │ │ ├── lib │ │ └── drop.ex │ │ ├── .gitignore │ │ └── README.md ├── ch06 │ ├── ex1-product │ │ ├── test │ │ │ ├── test_helper.exs │ │ │ └── overall_test.exs │ │ ├── lib │ │ │ └── overall.ex │ │ └── .gitignore │ ├── ex2-drop │ │ ├── test │ │ │ ├── test_helper.exs │ │ │ └── list_drop_test.exs │ │ ├── lib │ │ │ ├── list_drop.ex │ │ │ └── drop.ex │ │ └── .gitignore │ ├── ex3-drop │ │ ├── test │ │ │ ├── test_helper.exs │ │ │ └── list_drop_test.exs │ │ ├── lib │ │ │ ├── list_drop.ex │ │ │ └── drop.ex │ │ └── .gitignore │ └── ex4-pascal │ │ ├── test │ │ ├── test_helper.exs │ │ └── pascal_test.exs │ │ └── .gitignore ├── ch07 │ ├── ex1-struct │ │ ├── test │ │ │ ├── test_helper.exs │ │ │ └── tower_test.exs │ │ ├── lib │ │ │ ├── tower.ex │ │ │ └── planemo.ex │ │ └── .gitignore │ ├── ex7-inspect │ │ ├── test │ │ │ ├── test_helper.exs │ │ │ └── valid_test.exs │ │ ├── lib │ │ │ ├── valid.ex │ │ │ └── planemo.ex │ │ └── .gitignore │ ├── ex2-struct-match │ │ ├── test │ │ │ ├── test_helper.exs │ │ │ └── struct_drop_test.exs │ │ ├── lib │ │ │ ├── tower.ex │ │ │ ├── planemo.ex │ │ │ └── struct_drop.ex │ │ └── .gitignore │ ├── ex4-struct-multi │ │ ├── test │ │ │ ├── test_helper.exs │ │ │ └── struct_drop_test.exs │ │ ├── lib │ │ │ ├── tower.ex │ │ │ └── planemo.ex │ │ └── .gitignore │ ├── ex5-protocol │ │ ├── test │ │ │ ├── test_helper.exs │ │ │ └── valid_test.exs │ │ ├── lib │ │ │ ├── tower.ex │ │ │ ├── valid.ex │ │ │ └── planemo.ex │ │ └── .gitignore │ ├── ex6-protocol │ │ ├── test │ │ │ ├── test_helper.exs │ │ │ └── valid_test.exs │ │ ├── lib │ │ │ ├── valid.ex │ │ │ ├── tower.ex │ │ │ └── planemo.ex │ │ └── .gitignore │ └── ex3-struct-components │ │ ├── test │ │ ├── test_helper.exs │ │ └── struct_drop_test.exs │ │ ├── lib │ │ ├── tower.ex │ │ └── planemo.ex │ │ └── .gitignore ├── ch08 │ └── ex1-hof │ │ ├── test │ │ ├── test_helper.exs │ │ └── hof_test.exs │ │ ├── lib │ │ └── hof.ex │ │ ├── .gitignore │ │ └── README.md ├── ch10 │ ├── ex2-debug │ │ ├── test │ │ │ ├── test_helper.exs │ │ │ └── mph_drop_test.exs │ │ └── .gitignore │ ├── ex3-debug │ │ ├── test │ │ │ ├── test_helper.exs │ │ │ └── fact_test.exs │ │ ├── lib │ │ │ └── fact.ex │ │ ├── .gitignore │ │ └── README.md │ ├── ex1-tryCatch │ │ ├── test │ │ │ ├── test_helper.exs │ │ │ └── drop_test.exs │ │ ├── lib │ │ │ └── drop.ex │ │ ├── .gitignore │ │ └── README.md │ ├── ex1a-tryCatch │ │ ├── test │ │ │ ├── test_helper.exs │ │ │ └── drop_test.exs │ │ ├── lib │ │ │ └── drop.ex │ │ └── .gitignore │ └── ex1b-tryCatch │ │ ├── test │ │ ├── test_helper.exs │ │ └── drop_test.exs │ │ ├── lib │ │ └── drop.ex │ │ └── .gitignore ├── ch12 │ ├── ex1-records │ │ ├── test │ │ │ ├── test_helper.exs │ │ │ └── records_test.exs │ │ ├── lib │ │ │ └── records.ex │ │ └── .gitignore │ ├── ex2-records │ │ ├── test │ │ │ ├── test_helper.exs │ │ │ └── record_drop_test.exs │ │ ├── lib │ │ │ └── records.ex │ │ └── .gitignore │ ├── ex3-records │ │ ├── test │ │ │ ├── test_helper.exs │ │ │ └── record_drop_test.exs │ │ ├── lib │ │ │ └── records.ex │ │ └── .gitignore │ ├── ex4-records │ │ ├── test │ │ │ ├── test_helper.exs │ │ │ └── record_drop_test.exs │ │ ├── lib │ │ │ └── records.ex │ │ └── .gitignore │ ├── ex5-ets │ │ ├── test │ │ │ ├── test_helper.exs │ │ │ └── planemo_storage_test.exs │ │ ├── lib │ │ │ ├── planemo_storage.ex │ │ │ └── records.ex │ │ └── .gitignore │ ├── ex6-ets │ │ ├── test │ │ │ ├── test_helper.exs │ │ │ └── planemo_storage_test.exs │ │ ├── lib │ │ │ └── records.ex │ │ └── .gitignore │ ├── ex8-mnesia │ │ ├── test │ │ │ ├── test_helper.exs │ │ │ └── mph_drop_test.exs │ │ ├── Mnesia.nonode@nohost │ │ │ ├── LATEST.LOG │ │ │ ├── schema.DAT │ │ │ └── DECISION_TAB.LOG │ │ ├── lib │ │ │ └── records.ex │ │ └── .gitignore │ ├── ex7-ets-calculator │ │ ├── test │ │ │ ├── test_helper.exs │ │ │ └── mph_drop_test.exs │ │ ├── lib │ │ │ └── records.ex │ │ └── .gitignore │ └── tower_definitions.txt ├── ch13 │ ├── ex1-drop │ │ ├── test │ │ │ ├── test_helper.exs │ │ │ └── drop_server_test.exs │ │ └── .gitignore │ ├── ex2-drop-sup │ │ ├── test │ │ │ ├── test_helper.exs │ │ │ └── drop_sup_test.exs │ │ ├── lib │ │ │ └── drop_sup.ex │ │ └── .gitignore │ └── ex3-drop-app │ │ └── drop_app │ │ ├── test │ │ ├── test_helper.exs │ │ └── drop_app_test.exs │ │ └── lib │ │ ├── drop_app.ex │ │ └── drop_sup.ex ├── ch14 │ ├── ex2-double │ │ ├── test │ │ │ ├── test_helper.exs │ │ │ └── double_test.exs │ │ ├── lib │ │ │ ├── double.ex │ │ │ └── bad_double.ex │ │ └── .gitignore │ ├── ex3-double │ │ ├── test │ │ │ ├── test_helper.exs │ │ │ └── double_test.exs │ │ ├── lib │ │ │ └── double.ex │ │ └── .gitignore │ ├── ex4-unless │ │ ├── test │ │ │ ├── test_helper.exs │ │ │ └── logic_test.exs │ │ ├── lib │ │ │ └── logic.ex │ │ └── .gitignore │ ├── ex1-difference │ │ ├── test │ │ │ ├── test_helper.exs │ │ │ └── difference_test.exs │ │ ├── lib │ │ │ └── difference.ex │ │ └── .gitignore │ ├── ex5-programmatic │ │ ├── test │ │ │ ├── test_helper.exs │ │ │ └── multiply_test.exs │ │ ├── lib │ │ │ ├── function_maker.ex │ │ │ └── multiply.ex │ │ └── .gitignore │ └── ex6-multidrop │ │ ├── test │ │ ├── test_helper.exs │ │ └── drop_test.exs │ │ ├── lib │ │ ├── drop.ex │ │ └── function_maker.ex │ │ └── .gitignore ├── ch15 │ └── fall │ │ ├── test │ │ ├── test_helper.exs │ │ ├── views │ │ │ ├── page_view_test.exs │ │ │ └── layout_view_test.exs │ │ └── controllers │ │ │ └── page_controller_test.exs │ │ ├── web │ │ ├── views │ │ │ ├── fall.ex │ │ │ ├── layout_view.ex │ │ │ ├── page_view.ex │ │ │ └── error_view.ex │ │ ├── controllers │ │ │ └── page_controller.ex │ │ └── templates │ │ │ └── fall │ │ │ ├── welcome.html.eex │ │ │ └── faller.html.eex │ │ ├── priv │ │ ├── static │ │ │ ├── favicon.ico │ │ │ ├── images │ │ │ │ └── phoenix.png │ │ │ ├── robots.txt │ │ │ └── js │ │ │ │ └── app.js │ │ └── gettext │ │ │ ├── en │ │ │ └── LC_MESSAGES │ │ │ │ └── errors.po │ │ │ └── errors.pot │ │ ├── config │ │ └── test.exs │ │ └── .gitignore └── builder.pl ├── 1st-edition ├── appB │ └── ex1-docs │ │ ├── combined │ │ ├── test │ │ │ ├── test_helper.exs │ │ │ └── combined_test.exs │ │ ├── .gitignore │ │ ├── README.md │ │ ├── mix.lock │ │ └── docs │ │ │ └── index.html │ │ └── docs │ │ └── index.html ├── ch12 │ ├── ex3-drop-app │ │ └── drop_app │ │ │ ├── test │ │ │ ├── test_helper.exs │ │ │ └── drop_app_test.exs │ │ │ ├── .gitignore │ │ │ ├── README.md │ │ │ └── lib │ │ │ └── drop_app.ex │ ├── ex3-drop-app2 │ │ └── drop_app │ │ │ ├── test │ │ │ ├── test_helper.exs │ │ │ └── drop_app_test.exs │ │ │ ├── .gitignore │ │ │ ├── README.md │ │ │ └── lib │ │ │ └── drop_app.ex │ ├── ex1-drop │ │ └── testor.ex │ └── ex2-drop-sup │ │ └── drop_sup.ex ├── ch07 │ ├── ex1-struct │ │ ├── tower.ex │ │ └── planemo.ex │ ├── ex5-protocol │ │ ├── valid_protocol.ex │ │ ├── tower.ex │ │ └── planemo.ex │ ├── ex6-protocol │ │ ├── valid_protocol.ex │ │ ├── tower.ex │ │ └── planemo.ex │ ├── ex7-inspect │ │ ├── valid_protocol.ex │ │ └── planemo.ex │ ├── ex2-struct-match │ │ ├── structs.ex │ │ └── struct_drop.ex │ ├── ex4-struct-multi │ │ └── structs.ex │ └── ex3-struct-components │ │ └── structs.ex ├── ch08 │ └── ex1-hof │ │ └── hof.ex ├── ch11 │ ├── ex1-records │ │ ├── user.ex │ │ └── records.ex │ ├── ex9-qlc │ │ ├── records.ex │ │ └── test.ex │ ├── ex5-ets │ │ ├── planemo_storage.ex │ │ └── records.ex │ ├── ex6-ets │ │ └── records.ex │ ├── ex2-records │ │ └── records.ex │ ├── ex3-records │ │ └── records.ex │ ├── ex4-records │ │ └── records.ex │ ├── ex7-ets-calculator │ │ └── records.ex │ └── ex8-mnesia │ │ └── records.ex ├── ch13 │ ├── ex2-double │ │ └── double.ex │ ├── ex3-double │ │ └── double.ex │ ├── ex4-unless │ │ └── logic.ex │ ├── ex1-difference │ │ └── difference.ex │ ├── ex5-programmatic │ │ ├── function_maker.ex │ │ └── multiply.ex │ └── ex6-multidrop │ │ ├── drop.ex │ │ └── function_maker.ex ├── ch02 │ ├── ex2-split │ │ ├── drop.ex │ │ └── convert.ex │ ├── ex3-combined │ │ ├── drop.ex │ │ ├── combined.ex │ │ └── convert.ex │ ├── ex4-pipe │ │ ├── drop.ex │ │ ├── combined.ex │ │ └── convert.ex │ ├── ex6-defaults │ │ └── drop.ex │ ├── ex5-import │ │ ├── drop.ex │ │ ├── combined.ex │ │ └── convert.ex │ └── ex1-drop │ │ └── drop.ex ├── ch09 │ ├── ex3-counter │ │ ├── ttb_last_config │ │ └── bounce.ex │ ├── ex1-simple │ │ └── bounce.ex │ ├── ex2-recursion │ │ └── bounce.ex │ ├── ex5-division │ │ └── bounce.ex │ ├── ex4-state │ │ └── bounce.ex │ ├── ex4-testing │ │ ├── drop.ex │ │ ├── drop_bad.ex │ │ └── drop_test.exs │ └── ex3-debug │ │ └── fact.ex ├── ch03 │ ├── ex3-underscore │ │ ├── drop2.ex │ │ └── drop.ex │ ├── ex2-guards │ │ ├── mathDemo.ex │ │ └── drop.ex │ ├── ex1-atoms │ │ └── drop.ex │ ├── ex4-tuples │ │ └── drop.ex │ └── ex5-tuplesMore │ │ ├── drop2.ex │ │ ├── drop.ex │ │ └── drop3.ex ├── ch04 │ ├── ex9-factorial-down │ │ └── fact.ex │ ├── ex6-broken │ │ └── broken.ex │ ├── ex7-countdown │ │ └── count.ex │ ├── ex2-case │ │ └── drop.ex │ ├── ex1-case │ │ └── drop.ex │ ├── ex3-case │ │ └── drop.ex │ ├── ex8-countup │ │ └── count.ex │ ├── ex10-factorial-down-instrumented │ │ └── fact.ex │ ├── ex11-factorial-up │ │ └── fact.ex │ └── ex5-if │ │ └── drop.ex ├── ch05 │ ├── ex1-ask │ │ └── ask.ex │ └── ex2-ask │ │ └── drop.ex ├── ch10 │ ├── ex4-testing │ │ ├── drop.ex │ │ ├── drop_bad.ex │ │ └── drop_test.exs │ ├── ex1-tryCatch │ │ ├── drop.ex │ │ ├── drop2.ex │ │ └── drop3.ex │ └── ex3-debug │ │ └── fact.ex └── ch06 │ ├── ex2-drop │ ├── listdrop.ex │ └── drop.ex │ ├── ex3-drop │ ├── listdrop.ex │ └── drop.ex │ └── ex1-product │ └── overall.ex └── README.md /2nd-edition/ch04/ex1-case/xbuild/dev/lib/drop/.compile.xref: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /2nd-edition/ch04/ex5-if/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch09/testor/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch11/zorko/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch02/ex1-drop/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch02/ex2-split/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch02/ex4a-pipe/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch02/ex5-import/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch02/ex7-docs/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch03/ex1-atoms/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch03/ex2-guards/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch03/ex4-tuples/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch04/ex1-case/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch04/ex2-case/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch04/ex3-case/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch04/ex4-cond/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch04/ex6-broken/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch04/ex8-countup/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch05/ex1-ask/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch05/ex2-ask/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch05/ex3-ask/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch06/ex1-product/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch06/ex2-drop/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch06/ex3-drop/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch06/ex4-pascal/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch07/ex1-struct/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch07/ex7-inspect/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch08/ex1-hof/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch09/ex1-simple/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch09/ex3-counter/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch09/ex4-state/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch09/ex6-talking/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch09/ex8-linking/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch10/ex2-debug/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch10/ex3-debug/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch11/dia_test/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch11/ex1-guards/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch11/ex2-specs/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch11/ex3-specs/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch11/ex4-testing/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch11/ex5-setup/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch11/ex6-doctest/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch11/zorko/lib/zorko.ex: -------------------------------------------------------------------------------- 1 | defmodule Zorko do 2 | end 3 | -------------------------------------------------------------------------------- /2nd-edition/ch12/ex1-records/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch12/ex2-records/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch12/ex3-records/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch12/ex4-records/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch12/ex5-ets/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch12/ex6-ets/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch12/ex8-mnesia/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch13/ex1-drop/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch14/ex2-double/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch14/ex3-double/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch14/ex4-unless/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch15/fall/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start 2 | 3 | -------------------------------------------------------------------------------- /2nd-edition/ch02/ex10-doc-specs/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch02/ex11-doc-module/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch02/ex3-combined/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch02/ex4-combined/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch02/ex6-defaults/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch02/ex8-doc-function/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch03/absolute-value-1/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch03/absolute-value-2/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch03/ex3-underscore/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch03/ex5-tuplesMore/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch04/ex7-countdown/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch07/ex2-struct-match/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch07/ex4-struct-multi/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch07/ex5-protocol/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch07/ex6-protocol/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch09/ex10-resilient/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch09/ex2-recursion/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch09/ex5-division/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch09/ex7-talkingProcs/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch09/ex9-trapping/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch10/ex1-tryCatch/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch10/ex1a-tryCatch/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch10/ex1b-tryCatch/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch11/ex4a-testing/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch13/ex2-drop-sup/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch14/ex1-difference/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch14/ex5-programmatic/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch14/ex6-multidrop/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /1st-edition/appB/ex1-docs/combined/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /1st-edition/ch12/ex3-drop-app/drop_app/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch02/ex5-import-erlang/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch04/ex11-factorial-up/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch04/ex9-factorial-down/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch06/ex3-drop/lib/list_drop.ex: -------------------------------------------------------------------------------- 1 | defmodule ListDrop do 2 | end 3 | -------------------------------------------------------------------------------- /2nd-edition/ch07/ex3-struct-components/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch12/ex7-ets-calculator/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch13/ex3-drop-app/drop_app/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /1st-edition/ch12/ex3-drop-app2/drop_app/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch03/absolute-value-2/lib/math_demo.ex: -------------------------------------------------------------------------------- 1 | defmodule MathDemo do 2 | end 3 | -------------------------------------------------------------------------------- /2nd-edition/ch04/ex10-factorial-down-instrumented/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /2nd-edition/ch04/ex11-factorial-down-tail-recursive/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /1st-edition/appB/ex1-docs/combined/.gitignore: -------------------------------------------------------------------------------- 1 | /_build 2 | /deps 3 | erl_crash.dump 4 | *.ez 5 | -------------------------------------------------------------------------------- /1st-edition/ch12/ex3-drop-app/drop_app/.gitignore: -------------------------------------------------------------------------------- 1 | /_build 2 | /deps 3 | erl_crash.dump 4 | *.ez 5 | -------------------------------------------------------------------------------- /1st-edition/ch12/ex3-drop-app2/drop_app/.gitignore: -------------------------------------------------------------------------------- 1 | /_build 2 | /deps 3 | erl_crash.dump 4 | *.ez 5 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | introducing-elixir 2 | ================== 3 | 4 | Example code from Introducing Elixir. 5 | -------------------------------------------------------------------------------- /1st-edition/appB/ex1-docs/combined/README.md: -------------------------------------------------------------------------------- 1 | Combined 2 | ======== 3 | 4 | ** TODO: Add description ** 5 | -------------------------------------------------------------------------------- /1st-edition/ch12/ex3-drop-app/drop_app/README.md: -------------------------------------------------------------------------------- 1 | DropApp 2 | ======= 3 | 4 | ** TODO: Add description ** 5 | -------------------------------------------------------------------------------- /1st-edition/ch12/ex3-drop-app2/drop_app/README.md: -------------------------------------------------------------------------------- 1 | DropApp 2 | ======= 3 | 4 | ** TODO: Add description ** 5 | -------------------------------------------------------------------------------- /2nd-edition/ch15/fall/web/views/fall.ex: -------------------------------------------------------------------------------- 1 | defmodule Fall.FallView do 2 | use Fall.Web, :view 3 | end 4 | 5 | -------------------------------------------------------------------------------- /2nd-edition/ch15/fall/web/views/layout_view.ex: -------------------------------------------------------------------------------- 1 | defmodule Fall.LayoutView do 2 | use Fall.Web, :view 3 | end 4 | -------------------------------------------------------------------------------- /2nd-edition/ch15/fall/web/views/page_view.ex: -------------------------------------------------------------------------------- 1 | defmodule Fall.PageView do 2 | use Fall.Web, :view 3 | end 4 | -------------------------------------------------------------------------------- /1st-edition/ch12/ex1-drop/testor.ex: -------------------------------------------------------------------------------- 1 | defmodule Testor do 2 | def __struct__ do 3 | %{} 4 | end 5 | end 6 | 7 | -------------------------------------------------------------------------------- /2nd-edition/ch15/fall/test/views/page_view_test.exs: -------------------------------------------------------------------------------- 1 | defmodule Fall.PageViewTest do 2 | use Fall.ConnCase, async: true 3 | end 4 | -------------------------------------------------------------------------------- /1st-edition/ch07/ex1-struct/tower.ex: -------------------------------------------------------------------------------- 1 | defmodule Tower do 2 | defstruct location: "", height: 20, planemo: :earth, name: "" 3 | end 4 | -------------------------------------------------------------------------------- /1st-edition/ch08/ex1-hof/hof.ex: -------------------------------------------------------------------------------- 1 | defmodule Hof do 2 | def tripler(value, function) do 3 | 3 * function.(value) 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /2nd-edition/ch07/ex1-struct/lib/tower.ex: -------------------------------------------------------------------------------- 1 | defmodule Tower do 2 | defstruct location: "", height: 20, planemo: :earth, name: "" 3 | end -------------------------------------------------------------------------------- /2nd-edition/ch07/ex5-protocol/lib/tower.ex: -------------------------------------------------------------------------------- 1 | defmodule Tower do 2 | defstruct location: "", height: 20, planemo: :earth, name: "" 3 | end -------------------------------------------------------------------------------- /2nd-edition/ch11/ex6-doctest/test/drop_test.exs: -------------------------------------------------------------------------------- 1 | defmodule DropTest do 2 | use ExUnit.Case, async: false 3 | doctest Drop 4 | end 5 | -------------------------------------------------------------------------------- /2nd-edition/ch15/fall/test/views/layout_view_test.exs: -------------------------------------------------------------------------------- 1 | defmodule Fall.LayoutViewTest do 2 | use Fall.ConnCase, async: true 3 | end 4 | -------------------------------------------------------------------------------- /1st-edition/ch11/ex1-records/user.ex: -------------------------------------------------------------------------------- 1 | defmodule User do 2 | require Record; 3 | Record.defrecord :user, [name: "José", age: "25"] 4 | end -------------------------------------------------------------------------------- /1st-edition/ch13/ex2-double/double.ex: -------------------------------------------------------------------------------- 1 | defmodule Double do 2 | 3 | defmacro double x do 4 | {:*, [], [2, x]} 5 | end 6 | 7 | end 8 | -------------------------------------------------------------------------------- /2nd-edition/ch07/ex2-struct-match/lib/tower.ex: -------------------------------------------------------------------------------- 1 | defmodule Tower do 2 | defstruct location: "", height: 20, planemo: :earth, name: "" 3 | end -------------------------------------------------------------------------------- /2nd-edition/ch07/ex4-struct-multi/lib/tower.ex: -------------------------------------------------------------------------------- 1 | defmodule Tower do 2 | defstruct location: "", height: 20, planemo: :earth, name: "" 3 | end -------------------------------------------------------------------------------- /1st-edition/ch02/ex2-split/drop.ex: -------------------------------------------------------------------------------- 1 | defmodule Drop do 2 | def fall_velocity(distance) do 3 | :math.sqrt(2 * 9.8 * distance) 4 | end 5 | end -------------------------------------------------------------------------------- /1st-edition/ch02/ex3-combined/drop.ex: -------------------------------------------------------------------------------- 1 | defmodule Drop do 2 | def fall_velocity(distance) do 3 | :math.sqrt(2 * 9.8 * distance) 4 | end 5 | end -------------------------------------------------------------------------------- /1st-edition/ch02/ex4-pipe/drop.ex: -------------------------------------------------------------------------------- 1 | defmodule Drop do 2 | def fall_velocity(distance) do 3 | :math.sqrt(2 * 9.8 * distance) 4 | end 5 | end -------------------------------------------------------------------------------- /1st-edition/ch07/ex1-struct/planemo.ex: -------------------------------------------------------------------------------- 1 | defmodule Planemo do 2 | defstruct name: :nil, gravity: 0, diameter: 0, distance_from_sun: 0 3 | end 4 | -------------------------------------------------------------------------------- /2nd-edition/ch02/ex7-docs/lib/drop.ex: -------------------------------------------------------------------------------- 1 | defmodule Drop do 2 | def fall_velocity(distance) do 3 | :math.sqrt(2 * 9.8 * distance) 4 | end 5 | end -------------------------------------------------------------------------------- /2nd-edition/ch07/ex1-struct/lib/planemo.ex: -------------------------------------------------------------------------------- 1 | defmodule Planemo do 2 | defstruct name: :nil, gravity: 0, diameter: 0, distance_from_sun: 0 3 | end -------------------------------------------------------------------------------- /2nd-edition/ch07/ex3-struct-components/lib/tower.ex: -------------------------------------------------------------------------------- 1 | defmodule Tower do 2 | defstruct location: "", height: 20, planemo: :earth, name: "" 3 | end -------------------------------------------------------------------------------- /2nd-edition/ch08/ex1-hof/lib/hof.ex: -------------------------------------------------------------------------------- 1 | defmodule Hof do 2 | def tripler(value, function) do 3 | 3 * function.(value) 4 | end 5 | end 6 | 7 | -------------------------------------------------------------------------------- /2nd-edition/ch14/ex2-double/lib/double.ex: -------------------------------------------------------------------------------- 1 | defmodule Double do 2 | 3 | defmacro double x do 4 | {:*, [], [2, x]} 5 | end 6 | end 7 | 8 | -------------------------------------------------------------------------------- /1st-edition/ch09/ex3-counter/ttb_last_config: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simonstl/introducing-elixir/HEAD/1st-edition/ch09/ex3-counter/ttb_last_config -------------------------------------------------------------------------------- /2nd-edition/ch02/ex2-split/lib/drop.ex: -------------------------------------------------------------------------------- 1 | defmodule Drop do 2 | def fall_velocity(distance) do 3 | :math.sqrt(2 * 9.8 * distance) 4 | end 5 | end -------------------------------------------------------------------------------- /2nd-edition/ch02/ex3-combined/lib/drop.ex: -------------------------------------------------------------------------------- 1 | defmodule Drop do 2 | def fall_velocity(distance) do 3 | :math.sqrt(2 * 9.8 * distance) 4 | end 5 | end -------------------------------------------------------------------------------- /2nd-edition/ch02/ex4-combined/lib/drop.ex: -------------------------------------------------------------------------------- 1 | defmodule Drop do 2 | def fall_velocity(distance) do 3 | :math.sqrt(2 * 9.8 * distance) 4 | end 5 | end -------------------------------------------------------------------------------- /2nd-edition/ch02/ex4a-pipe/lib/drop.ex: -------------------------------------------------------------------------------- 1 | defmodule Drop do 2 | def fall_velocity(distance) do 3 | :math.sqrt(2 * 9.8 * distance) 4 | end 5 | end -------------------------------------------------------------------------------- /2nd-edition/ch02/ex5-import/lib/drop.ex: -------------------------------------------------------------------------------- 1 | defmodule Drop do 2 | def fall_velocity(distance) do 3 | :math.sqrt(2 * 9.8 * distance) 4 | end 5 | end -------------------------------------------------------------------------------- /2nd-edition/ch07/ex2-struct-match/lib/planemo.ex: -------------------------------------------------------------------------------- 1 | defmodule Planemo do 2 | defstruct name: :nil, gravity: 0, diameter: 0, distance_from_sun: 0 3 | end -------------------------------------------------------------------------------- /2nd-edition/ch07/ex4-struct-multi/lib/planemo.ex: -------------------------------------------------------------------------------- 1 | defmodule Planemo do 2 | defstruct name: :nil, gravity: 0, diameter: 0, distance_from_sun: 0 3 | end -------------------------------------------------------------------------------- /2nd-edition/ch15/fall/priv/static/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simonstl/introducing-elixir/HEAD/2nd-edition/ch15/fall/priv/static/favicon.ico -------------------------------------------------------------------------------- /2nd-edition/ch07/ex3-struct-components/lib/planemo.ex: -------------------------------------------------------------------------------- 1 | defmodule Planemo do 2 | defstruct name: :nil, gravity: 0, diameter: 0, distance_from_sun: 0 3 | end -------------------------------------------------------------------------------- /2nd-edition/ch07/ex5-protocol/lib/valid.ex: -------------------------------------------------------------------------------- 1 | defprotocol Valid do 2 | @doc "Returns true if data is considered nominally valid" 3 | def valid?(data) 4 | end -------------------------------------------------------------------------------- /2nd-edition/ch07/ex6-protocol/lib/valid.ex: -------------------------------------------------------------------------------- 1 | defprotocol Valid do 2 | @doc "Returns true if data is considered nominally valid" 3 | def valid?(data) 4 | end -------------------------------------------------------------------------------- /2nd-edition/ch07/ex7-inspect/lib/valid.ex: -------------------------------------------------------------------------------- 1 | defprotocol Valid do 2 | @doc "Returns true if data is considered nominally valid" 3 | def valid?(data) 4 | end -------------------------------------------------------------------------------- /2nd-edition/ch14/ex2-double/lib/bad_double.ex: -------------------------------------------------------------------------------- 1 | defmodule BadDouble do 2 | 3 | defmacro double(x) do 4 | quote do: 2 * x 5 | end 6 | 7 | end 8 | 9 | -------------------------------------------------------------------------------- /1st-edition/ch02/ex6-defaults/drop.ex: -------------------------------------------------------------------------------- 1 | defmodule Drop do 2 | def fall_velocity(distance, gravity \\ 9.8) do 3 | :math.sqrt(2 * gravity * distance) 4 | end 5 | end -------------------------------------------------------------------------------- /1st-edition/ch07/ex5-protocol/valid_protocol.ex: -------------------------------------------------------------------------------- 1 | defprotocol Valid do 2 | @doc "Returns true if data is considered nominally valid" 3 | def valid?(data) 4 | end 5 | -------------------------------------------------------------------------------- /1st-edition/ch07/ex6-protocol/valid_protocol.ex: -------------------------------------------------------------------------------- 1 | defprotocol Valid do 2 | @doc "Returns true if data is considered nominally valid" 3 | def valid?(data) 4 | end 5 | -------------------------------------------------------------------------------- /1st-edition/ch07/ex7-inspect/valid_protocol.ex: -------------------------------------------------------------------------------- 1 | defprotocol Valid do 2 | @doc "Returns true if data is considered nominally valid" 3 | def valid?(data) 4 | end 5 | -------------------------------------------------------------------------------- /2nd-edition/ch15/fall/priv/static/images/phoenix.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simonstl/introducing-elixir/HEAD/2nd-edition/ch15/fall/priv/static/images/phoenix.png -------------------------------------------------------------------------------- /1st-edition/ch02/ex3-combined/combined.ex: -------------------------------------------------------------------------------- 1 | defmodule Combined do 2 | def height_to_mph(meters) do 3 | Convert.mps_to_mph(Drop.fall_velocity(meters)) 4 | end 5 | end -------------------------------------------------------------------------------- /1st-edition/ch02/ex4-pipe/combined.ex: -------------------------------------------------------------------------------- 1 | defmodule Combined do 2 | def height_to_mph(meters) do 3 | Drop.fall_velocity(meters) |> Convert.mps_to_mph 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /1st-edition/ch09/ex1-simple/bounce.ex: -------------------------------------------------------------------------------- 1 | defmodule Bounce do 2 | def report do 3 | receive do 4 | msg -> IO.puts("Received #{msg}") 5 | end 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /2nd-edition/ch02/ex4a-pipe/lib/combined.ex: -------------------------------------------------------------------------------- 1 | defmodule Combined do 2 | def height_to_mph(meters) do 3 | Drop.fall_velocity(meters) |> Convert.mps_to_mph 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /2nd-edition/ch02/ex6-defaults/lib/drop.ex: -------------------------------------------------------------------------------- 1 | defmodule Drop do 2 | def fall_velocity(distance, gravity \\ 9.8) do 3 | :math.sqrt(2 * gravity * distance) 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /1st-edition/ch13/ex3-double/double.ex: -------------------------------------------------------------------------------- 1 | defmodule Double do 2 | 3 | defmacro double(x) do 4 | quote do 5 | 2 * unquote(x) 6 | end 7 | end 8 | 9 | end 10 | -------------------------------------------------------------------------------- /2nd-edition/ch02/ex10-doc-specs/lib/combined.ex: -------------------------------------------------------------------------------- 1 | defmodule Combined do 2 | def height_to_mph(meters) do 3 | Convert.mps_to_mph(Drop.fall_velocity(meters)) 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /2nd-edition/ch02/ex11-doc-module/lib/combined.ex: -------------------------------------------------------------------------------- 1 | defmodule Combined do 2 | def height_to_mph(meters) do 3 | Convert.mps_to_mph(Drop.fall_velocity(meters)) 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /2nd-edition/ch02/ex3-combined/lib/combined.ex: -------------------------------------------------------------------------------- 1 | defmodule Combined do 2 | def height_to_mph(meters) do 3 | Convert.mps_to_mph(Drop.fall_velocity(meters)) 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /2nd-edition/ch02/ex4-combined/lib/combined.ex: -------------------------------------------------------------------------------- 1 | defmodule Combined do 2 | def height_to_mph(meters) do 3 | Convert.mps_to_mph(Drop.fall_velocity(meters)) 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /2nd-edition/ch02/ex5-import-erlang/lib/drop.ex: -------------------------------------------------------------------------------- 1 | defmodule Drop do 2 | import :math 3 | 4 | def fall_velocity(distance) do 5 | sqrt(2 * 9.8 * distance) 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /2nd-edition/ch02/ex8-doc-function/lib/combined.ex: -------------------------------------------------------------------------------- 1 | defmodule Combined do 2 | def height_to_mph(meters) do 3 | Convert.mps_to_mph(Drop.fall_velocity(meters)) 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /2nd-edition/ch05/ex1-ask/test/ask_test.exs: -------------------------------------------------------------------------------- 1 | defmodule AskTest do 2 | use ExUnit.Case 3 | doctest Ask 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch05/ex2-ask/test/ask_test.exs: -------------------------------------------------------------------------------- 1 | defmodule AskTest do 2 | use ExUnit.Case 3 | doctest Ask 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch05/ex3-ask/test/ask_test.exs: -------------------------------------------------------------------------------- 1 | defmodule AskTest do 2 | use ExUnit.Case 3 | doctest Ask 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch08/ex1-hof/test/hof_test.exs: -------------------------------------------------------------------------------- 1 | defmodule HofTest do 2 | use ExUnit.Case 3 | doctest Hof 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch09/ex1-simple/lib/bounce.ex: -------------------------------------------------------------------------------- 1 | defmodule Bounce do 2 | def report do 3 | receive do 4 | msg -> IO.puts("Received #{msg}") 5 | end 6 | end 7 | end 8 | 9 | -------------------------------------------------------------------------------- /2nd-edition/ch12/ex8-mnesia/Mnesia.nonode@nohost/LATEST.LOG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simonstl/introducing-elixir/HEAD/2nd-edition/ch12/ex8-mnesia/Mnesia.nonode@nohost/LATEST.LOG -------------------------------------------------------------------------------- /2nd-edition/ch12/ex8-mnesia/Mnesia.nonode@nohost/schema.DAT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simonstl/introducing-elixir/HEAD/2nd-edition/ch12/ex8-mnesia/Mnesia.nonode@nohost/schema.DAT -------------------------------------------------------------------------------- /1st-edition/appB/ex1-docs/combined/test/combined_test.exs: -------------------------------------------------------------------------------- 1 | defmodule CombinedTest do 2 | use ExUnit.Case 3 | 4 | test "the truth" do 5 | assert 1 + 1 == 2 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /1st-edition/ch02/ex2-split/convert.ex: -------------------------------------------------------------------------------- 1 | defmodule Convert do 2 | def mps_to_mph(mps) do 3 | 2.23693629 * mps 4 | end 5 | 6 | def mps_to_kph(mps) do 7 | 3.6 * mps 8 | end 9 | end -------------------------------------------------------------------------------- /1st-edition/ch02/ex4-pipe/convert.ex: -------------------------------------------------------------------------------- 1 | defmodule Convert do 2 | def mps_to_mph(mps) do 3 | 2.23693629 * mps 4 | end 5 | 6 | def mps_to_kph(mps) do 7 | 3.6 * mps 8 | end 9 | end -------------------------------------------------------------------------------- /1st-edition/ch02/ex5-import/drop.ex: -------------------------------------------------------------------------------- 1 | defmodule Drop do 2 | def fall_velocity(distance) do 3 | import :math, only: [sqrt: 1] 4 | sqrt(2 * 9.8 * distance) 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /1st-edition/ch03/ex3-underscore/drop2.ex: -------------------------------------------------------------------------------- 1 | defmodule Drop2 do 2 | 3 | def fall_velocity(_, distance) when distance >= 0 do 4 | :math.sqrt(2 * 9.8 * distance) 5 | end 6 | 7 | end -------------------------------------------------------------------------------- /1st-edition/ch12/ex3-drop-app/drop_app/test/drop_app_test.exs: -------------------------------------------------------------------------------- 1 | defmodule DropAppTest do 2 | use ExUnit.Case 3 | 4 | test "the truth" do 5 | assert 1 + 1 == 2 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /1st-edition/ch12/ex3-drop-app2/drop_app/test/drop_app_test.exs: -------------------------------------------------------------------------------- 1 | defmodule DropAppTest do 2 | use ExUnit.Case 3 | 4 | test "the truth" do 5 | assert 1 + 1 == 2 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /2nd-edition/ch02/ex1-drop/test/drop_test.exs: -------------------------------------------------------------------------------- 1 | defmodule DropTest do 2 | use ExUnit.Case 3 | doctest Drop 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch02/ex2-split/test/drop_test.exs: -------------------------------------------------------------------------------- 1 | defmodule DropTest do 2 | use ExUnit.Case 3 | doctest Drop 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch03/ex1-atoms/test/drop_test.exs: -------------------------------------------------------------------------------- 1 | defmodule DropTest do 2 | use ExUnit.Case 3 | doctest Drop 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch03/ex2-guards/test/drop_test.exs: -------------------------------------------------------------------------------- 1 | defmodule DropTest do 2 | use ExUnit.Case 3 | doctest Drop 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch03/ex3-underscore/lib/drop2.ex: -------------------------------------------------------------------------------- 1 | defmodule Drop2 do 2 | 3 | def fall_velocity(_, distance) when distance >= 0 do 4 | :math.sqrt(2 * 9.8 * distance) 5 | end 6 | 7 | end -------------------------------------------------------------------------------- /2nd-edition/ch03/ex4-tuples/test/drop_test.exs: -------------------------------------------------------------------------------- 1 | defmodule DropTest do 2 | use ExUnit.Case 3 | doctest Drop 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch04/ex1-case/test/drop_test.exs: -------------------------------------------------------------------------------- 1 | defmodule DropTest do 2 | use ExUnit.Case 3 | doctest Drop 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch04/ex1-case/xbuild/dev/lib/drop/.compile.elixir: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simonstl/introducing-elixir/HEAD/2nd-edition/ch04/ex1-case/xbuild/dev/lib/drop/.compile.elixir -------------------------------------------------------------------------------- /2nd-edition/ch04/ex2-case/test/drop_test.exs: -------------------------------------------------------------------------------- 1 | defmodule DropTest do 2 | use ExUnit.Case 3 | doctest Drop 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch04/ex3-case/test/drop_test.exs: -------------------------------------------------------------------------------- 1 | defmodule DropTest do 2 | use ExUnit.Case 3 | doctest Drop 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch04/ex4-cond/test/drop_test.exs: -------------------------------------------------------------------------------- 1 | defmodule DropTest do 2 | use ExUnit.Case 3 | doctest Drop 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch04/ex5-if/test/drop_test.exs: -------------------------------------------------------------------------------- 1 | defmodule DropTest do 2 | use ExUnit.Case 3 | doctest Drop 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch10/ex3-debug/test/fact_test.exs: -------------------------------------------------------------------------------- 1 | defmodule FactTest do 2 | use ExUnit.Case 3 | doctest Fact 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch11/ex1-guards/test/drop_test.exs: -------------------------------------------------------------------------------- 1 | defmodule DropTest do 2 | use ExUnit.Case 3 | doctest Drop 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch11/zorko/test/zorko_test.exs: -------------------------------------------------------------------------------- 1 | defmodule ZorkoTest do 2 | use ExUnit.Case 3 | doctest Zorko 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /1st-edition/ch02/ex3-combined/convert.ex: -------------------------------------------------------------------------------- 1 | defmodule Convert do 2 | def mps_to_mph(mps) do 3 | 2.23693629 * mps 4 | end 5 | 6 | def mps_to_kph(mps) do 7 | 3.6 * mps 8 | end 9 | end -------------------------------------------------------------------------------- /1st-edition/ch02/ex5-import/combined.ex: -------------------------------------------------------------------------------- 1 | defmodule Combined do 2 | 3 | import Convert 4 | 5 | def height_to_mph(meters) do 6 | mps_to_mph(Drop.fall_velocity(meters)) 7 | end 8 | end -------------------------------------------------------------------------------- /1st-edition/ch02/ex5-import/convert.ex: -------------------------------------------------------------------------------- 1 | defmodule Convert do 2 | def mps_to_mph(mps) do 3 | 2.23693629 * mps 4 | end 5 | 6 | def mps_to_kph(mps) do 7 | 3.6 * mps 8 | end 9 | end -------------------------------------------------------------------------------- /1st-edition/ch03/ex3-underscore/drop.ex: -------------------------------------------------------------------------------- 1 | defmodule Drop do 2 | 3 | def fall_velocity(planemo, distance) when distance >= 0 do 4 | :math.sqrt(2 * 9.8 * distance) 5 | end 6 | 7 | end -------------------------------------------------------------------------------- /1st-edition/ch11/ex9-qlc/records.ex: -------------------------------------------------------------------------------- 1 | defrecord Planemo, name: :nil, gravity: 0, diameter: 0, distance_from_sun: 0 2 | defrecord Tower, location: "", height: 20, planemo: :earth, name: "" 3 | -------------------------------------------------------------------------------- /2nd-edition/ch02/ex2-split/lib/convert.ex: -------------------------------------------------------------------------------- 1 | defmodule Convert do 2 | def mps_to_mph(mps) do 3 | 2.23693629 * mps 4 | end 5 | 6 | def mps_to_kph(mps) do 7 | 3.6 * mps 8 | end 9 | end -------------------------------------------------------------------------------- /2nd-edition/ch02/ex4a-pipe/lib/convert.ex: -------------------------------------------------------------------------------- 1 | defmodule Convert do 2 | def mps_to_mph(mps) do 3 | 2.23693629 * mps 4 | end 5 | 6 | def mps_to_kph(mps) do 7 | 3.6 * mps 8 | end 9 | end -------------------------------------------------------------------------------- /2nd-edition/ch02/ex5-import/lib/combined.ex: -------------------------------------------------------------------------------- 1 | defmodule Combined do 2 | import Convert 3 | def height_to_mph(meters) do 4 | mps_to_mph(Drop.fall_velocity(meters)) 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /2nd-edition/ch02/ex5-import/lib/convert.ex: -------------------------------------------------------------------------------- 1 | defmodule Convert do 2 | def mps_to_mph(mps) do 3 | 2.23693629 * mps 4 | end 5 | 6 | def mps_to_kph(mps) do 7 | 3.6 * mps 8 | end 9 | end -------------------------------------------------------------------------------- /2nd-edition/ch02/ex6-defaults/test/drop_test.exs: -------------------------------------------------------------------------------- 1 | defmodule DropTest do 2 | use ExUnit.Case 3 | doctest Drop 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch02/ex7-docs/lib/convert.ex: -------------------------------------------------------------------------------- 1 | defmodule Convert do 2 | def mps_to_mph(mps) do 3 | 2.23693629 * mps 4 | end 5 | 6 | def mps_to_kph(mps) do 7 | 3.6 * mps 8 | end 9 | end -------------------------------------------------------------------------------- /2nd-edition/ch03/ex3-underscore/lib/drop.ex: -------------------------------------------------------------------------------- 1 | defmodule Drop do 2 | 3 | def fall_velocity(planemo, distance) when distance >= 0 do 4 | :math.sqrt(2 * 9.8 * distance) 5 | end 6 | 7 | end -------------------------------------------------------------------------------- /2nd-edition/ch03/ex3-underscore/test/drop_test.exs: -------------------------------------------------------------------------------- 1 | defmodule DropTest do 2 | use ExUnit.Case 3 | doctest Drop 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch03/ex5-tuplesMore/test/drop_test.exs: -------------------------------------------------------------------------------- 1 | defmodule DropTest do 2 | use ExUnit.Case 3 | doctest Drop 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch04/ex1-case/xbuild/dev/lib/drop/.compile.elixir_scm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simonstl/introducing-elixir/HEAD/2nd-edition/ch04/ex1-case/xbuild/dev/lib/drop/.compile.elixir_scm -------------------------------------------------------------------------------- /2nd-edition/ch04/ex8-countup/test/count_test.exs: -------------------------------------------------------------------------------- 1 | defmodule CountTest do 2 | use ExUnit.Case 3 | doctest Count 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch07/ex1-struct/test/tower_test.exs: -------------------------------------------------------------------------------- 1 | defmodule TowerTest do 2 | use ExUnit.Case 3 | doctest Tower 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch07/ex5-protocol/test/valid_test.exs: -------------------------------------------------------------------------------- 1 | defmodule ValidTest do 2 | use ExUnit.Case 3 | doctest Valid 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch07/ex6-protocol/test/valid_test.exs: -------------------------------------------------------------------------------- 1 | defmodule ValidTest do 2 | use ExUnit.Case 3 | doctest Valid 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch07/ex7-inspect/test/valid_test.exs: -------------------------------------------------------------------------------- 1 | defmodule ValidTest do 2 | use ExUnit.Case 3 | doctest Valid 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch09/ex4-state/test/bounce_test.exs: -------------------------------------------------------------------------------- 1 | defmodule BounceTest do 2 | use ExUnit.Case 3 | doctest Bounce 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch09/ex6-talking/test/drop_test.exs: -------------------------------------------------------------------------------- 1 | defmodule DropTest do 2 | use ExUnit.Case 3 | doctest Drop 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch10/ex1-tryCatch/test/drop_test.exs: -------------------------------------------------------------------------------- 1 | defmodule DropTest do 2 | use ExUnit.Case 3 | doctest Drop 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch10/ex1a-tryCatch/test/drop_test.exs: -------------------------------------------------------------------------------- 1 | defmodule DropTest do 2 | use ExUnit.Case 3 | doctest Drop 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch10/ex1b-tryCatch/test/drop_test.exs: -------------------------------------------------------------------------------- 1 | defmodule DropTest do 2 | use ExUnit.Case 3 | doctest Drop 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch11/ex2-specs/test/specs_test.exs: -------------------------------------------------------------------------------- 1 | defmodule SpecsTest do 2 | use ExUnit.Case 3 | doctest Specs 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch12/ex8-mnesia/Mnesia.nonode@nohost/DECISION_TAB.LOG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simonstl/introducing-elixir/HEAD/2nd-edition/ch12/ex8-mnesia/Mnesia.nonode@nohost/DECISION_TAB.LOG -------------------------------------------------------------------------------- /2nd-edition/ch14/ex3-double/lib/double.ex: -------------------------------------------------------------------------------- 1 | defmodule Double do 2 | 3 | defmacro double(x) do 4 | quote do 5 | 2 * unquote(x) 6 | end 7 | end 8 | 9 | end 10 | 11 | -------------------------------------------------------------------------------- /2nd-edition/ch14/ex4-unless/test/logic_test.exs: -------------------------------------------------------------------------------- 1 | defmodule LogicTest do 2 | use ExUnit.Case 3 | doctest Logic 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch14/ex6-multidrop/test/drop_test.exs: -------------------------------------------------------------------------------- 1 | defmodule DropTest do 2 | use ExUnit.Case 3 | doctest Drop 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /1st-edition/ch09/ex2-recursion/bounce.ex: -------------------------------------------------------------------------------- 1 | defmodule Bounce do 2 | def report do 3 | receive do 4 | msg -> IO.puts("Received #{msg}") 5 | report() 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch02/ex10-doc-specs/lib/convert.ex: -------------------------------------------------------------------------------- 1 | defmodule Convert do 2 | def mps_to_mph(mps) do 3 | 2.23693629 * mps 4 | end 5 | 6 | def mps_to_kph(mps) do 7 | 3.6 * mps 8 | end 9 | end -------------------------------------------------------------------------------- /2nd-edition/ch02/ex11-doc-module/lib/convert.ex: -------------------------------------------------------------------------------- 1 | defmodule Convert do 2 | def mps_to_mph(mps) do 3 | 2.23693629 * mps 4 | end 5 | 6 | def mps_to_kph(mps) do 7 | 3.6 * mps 8 | end 9 | end -------------------------------------------------------------------------------- /2nd-edition/ch02/ex3-combined/lib/convert.ex: -------------------------------------------------------------------------------- 1 | defmodule Convert do 2 | def mps_to_mph(mps) do 3 | 2.23693629 * mps 4 | end 5 | 6 | def mps_to_kph(mps) do 7 | 3.6 * mps 8 | end 9 | end -------------------------------------------------------------------------------- /2nd-edition/ch02/ex4-combined/lib/convert.ex: -------------------------------------------------------------------------------- 1 | defmodule Convert do 2 | def mps_to_mph(mps) do 3 | 2.23693629 * mps 4 | end 5 | 6 | def mps_to_kph(mps) do 7 | 3.6 * mps 8 | end 9 | end -------------------------------------------------------------------------------- /2nd-edition/ch02/ex5-import-erlang/test/drop_test.exs: -------------------------------------------------------------------------------- 1 | defmodule DropTest do 2 | use ExUnit.Case 3 | doctest Drop 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch02/ex7-docs/test/combined_test.exs: -------------------------------------------------------------------------------- 1 | defmodule CombinedTest do 2 | use ExUnit.Case 3 | doctest Combined 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch04/ex11-factorial-up/test/fact_test.exs: -------------------------------------------------------------------------------- 1 | defmodule FactTest do 2 | use ExUnit.Case 3 | doctest Fact 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch04/ex6-broken/test/broken_test.exs: -------------------------------------------------------------------------------- 1 | defmodule BrokenTest do 2 | use ExUnit.Case 3 | doctest Broken 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch04/ex7-countdown/test/count_test.exs: -------------------------------------------------------------------------------- 1 | defmodule CountTest do 2 | use ExUnit.Case 3 | doctest Count 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch04/ex9-factorial-down/test/fact_test.exs: -------------------------------------------------------------------------------- 1 | defmodule FactTest do 2 | use ExUnit.Case 3 | doctest Fact 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch06/ex1-product/test/overall_test.exs: -------------------------------------------------------------------------------- 1 | defmodule OverallTest do 2 | use ExUnit.Case 3 | doctest Overall 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch06/ex4-pascal/test/pascal_test.exs: -------------------------------------------------------------------------------- 1 | defmodule PascalTest do 2 | use ExUnit.Case 3 | doctest Pascal 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch09/ex1-simple/test/bounce_test.exs: -------------------------------------------------------------------------------- 1 | defmodule BounceTest do 2 | use ExUnit.Case 3 | doctest Bounce 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch09/ex2-recursion/test/bounce_test.exs: -------------------------------------------------------------------------------- 1 | defmodule BounceTest do 2 | use ExUnit.Case 3 | doctest Bounce 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch09/ex3-counter/test/bounce_test.exs: -------------------------------------------------------------------------------- 1 | defmodule BounceTest do 2 | use ExUnit.Case 3 | doctest Bounce 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch09/ex5-division/test/bounce_test.exs: -------------------------------------------------------------------------------- 1 | defmodule BounceTest do 2 | use ExUnit.Case 3 | doctest Bounce 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch09/testor/test/mph_drop_test.exs: -------------------------------------------------------------------------------- 1 | defmodule MphDropTest do 2 | use ExUnit.Case 3 | doctest MphDrop 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch10/ex2-debug/test/mph_drop_test.exs: -------------------------------------------------------------------------------- 1 | defmodule MphDropTest do 2 | use ExUnit.Case 3 | doctest MphDrop 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch11/dia_test/test/dia_test_test.exs: -------------------------------------------------------------------------------- 1 | defmodule DiaTestTest do 2 | use ExUnit.Case 3 | doctest DiaTest 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch11/ex3-specs/test/new_type_test.exs: -------------------------------------------------------------------------------- 1 | defmodule NewTypeTest do 2 | use ExUnit.Case 3 | doctest NewType 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch12/ex1-records/test/records_test.exs: -------------------------------------------------------------------------------- 1 | defmodule RecordsTest do 2 | use ExUnit.Case 3 | doctest Records 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch12/ex8-mnesia/test/mph_drop_test.exs: -------------------------------------------------------------------------------- 1 | defmodule MphDropTest do 2 | use ExUnit.Case 3 | doctest MphDrop 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch14/ex2-double/test/double_test.exs: -------------------------------------------------------------------------------- 1 | defmodule DoubleTest do 2 | use ExUnit.Case 3 | doctest Double 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch14/ex3-double/test/double_test.exs: -------------------------------------------------------------------------------- 1 | defmodule DoubleTest do 2 | use ExUnit.Case 3 | doctest Double 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch02/ex3-combined/test/combined_test.exs: -------------------------------------------------------------------------------- 1 | defmodule CombinedTest do 2 | use ExUnit.Case 3 | doctest Combined 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch02/ex4-combined/test/combined_test.exs: -------------------------------------------------------------------------------- 1 | defmodule CombinedTest do 2 | use ExUnit.Case 3 | doctest Combined 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch02/ex4a-pipe/test/combined_test.exs: -------------------------------------------------------------------------------- 1 | defmodule CombinedTest do 2 | use ExUnit.Case 3 | doctest Combined 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch02/ex5-import/test/combined_test.exs: -------------------------------------------------------------------------------- 1 | defmodule CombinedTest do 2 | use ExUnit.Case 3 | doctest Combined 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch02/ex8-doc-function/lib/convert.ex: -------------------------------------------------------------------------------- 1 | defmodule Convert do 2 | def mps_to_mph(mps) do 3 | 2.23693629 * mps 4 | end 5 | 6 | def mps_to_kph(mps) do 7 | 3.6 * mps 8 | end 9 | end -------------------------------------------------------------------------------- /2nd-edition/ch04/ex1-case/xbuild/dev/consolidated/.compile.protocols: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simonstl/introducing-elixir/HEAD/2nd-edition/ch04/ex1-case/xbuild/dev/consolidated/.compile.protocols -------------------------------------------------------------------------------- /2nd-edition/ch06/ex2-drop/test/list_drop_test.exs: -------------------------------------------------------------------------------- 1 | defmodule ListDropTest do 2 | use ExUnit.Case 3 | doctest ListDrop 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch06/ex3-drop/test/list_drop_test.exs: -------------------------------------------------------------------------------- 1 | defmodule ListDropTest do 2 | use ExUnit.Case 3 | doctest ListDrop 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch09/ex10-resilient/test/mph_drop_test.exs: -------------------------------------------------------------------------------- 1 | defmodule MphDropTest do 2 | use ExUnit.Case 3 | doctest MphDrop 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch09/ex8-linking/test/mph_drop_test.exs: -------------------------------------------------------------------------------- 1 | defmodule MphDropTest do 2 | use ExUnit.Case 3 | doctest MphDrop 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch09/ex9-trapping/test/mph_drop_test.exs: -------------------------------------------------------------------------------- 1 | defmodule MphDropTest do 2 | use ExUnit.Case 3 | doctest MphDrop 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch13/ex2-drop-sup/test/drop_sup_test.exs: -------------------------------------------------------------------------------- 1 | defmodule DropSupTest do 2 | use ExUnit.Case 3 | doctest DropSup 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch02/ex10-doc-specs/test/combined_test.exs: -------------------------------------------------------------------------------- 1 | defmodule CombinedTest do 2 | use ExUnit.Case 3 | doctest Combined 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch02/ex11-doc-module/test/combined_test.exs: -------------------------------------------------------------------------------- 1 | defmodule CombinedTest do 2 | use ExUnit.Case 3 | doctest Combined 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch02/ex8-doc-function/test/combined_test.exs: -------------------------------------------------------------------------------- 1 | defmodule CombinedTest do 2 | use ExUnit.Case 3 | doctest Combined 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch03/absolute-value-1/test/math_demo_test.exs: -------------------------------------------------------------------------------- 1 | defmodule MathDemoTest do 2 | use ExUnit.Case 3 | doctest MathDemo 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch03/absolute-value-2/test/math_demo_test.exs: -------------------------------------------------------------------------------- 1 | defmodule MathDemoTest do 2 | use ExUnit.Case 3 | doctest MathDemo 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch09/ex7-talkingProcs/test/mph_drop_test.exs: -------------------------------------------------------------------------------- 1 | defmodule MphDropTest do 2 | use ExUnit.Case 3 | doctest MphDrop 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch12/ex2-records/test/record_drop_test.exs: -------------------------------------------------------------------------------- 1 | defmodule RecordDropTest do 2 | use ExUnit.Case 3 | doctest RecordDrop 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch12/ex3-records/test/record_drop_test.exs: -------------------------------------------------------------------------------- 1 | defmodule RecordDropTest do 2 | use ExUnit.Case 3 | doctest RecordDrop 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch12/ex4-records/test/record_drop_test.exs: -------------------------------------------------------------------------------- 1 | defmodule RecordDropTest do 2 | use ExUnit.Case 3 | doctest RecordDrop 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch12/ex7-ets-calculator/test/mph_drop_test.exs: -------------------------------------------------------------------------------- 1 | defmodule MphDropTest do 2 | use ExUnit.Case 3 | doctest MphDrop 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch13/ex1-drop/test/drop_server_test.exs: -------------------------------------------------------------------------------- 1 | defmodule DropServerTest do 2 | use ExUnit.Case 3 | doctest DropServer 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch14/ex5-programmatic/test/multiply_test.exs: -------------------------------------------------------------------------------- 1 | defmodule MultiplyTest do 2 | use ExUnit.Case 3 | doctest Multiply 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /1st-edition/ch09/ex5-division/bounce.ex: -------------------------------------------------------------------------------- 1 | defmodule Bounce do 2 | def report do 3 | receive do 4 | x -> IO.puts("Divided to #{x / 2}") 5 | report() 6 | end 7 | end 8 | end 9 | 10 | -------------------------------------------------------------------------------- /2nd-edition/ch04/ex10-factorial-down-instrumented/test/fact_test.exs: -------------------------------------------------------------------------------- 1 | defmodule FactTest do 2 | use ExUnit.Case 3 | doctest Fact 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch04/ex11-factorial-down-tail-recursive/test/fact_test.exs: -------------------------------------------------------------------------------- 1 | defmodule FactTest do 2 | use ExUnit.Case 3 | doctest Fact 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch07/ex2-struct-match/test/struct_drop_test.exs: -------------------------------------------------------------------------------- 1 | defmodule StructDropTest do 2 | use ExUnit.Case 3 | doctest StructDrop 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch07/ex4-struct-multi/test/struct_drop_test.exs: -------------------------------------------------------------------------------- 1 | defmodule StructDropTest do 2 | use ExUnit.Case 3 | doctest StructDrop 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch13/ex3-drop-app/drop_app/test/drop_app_test.exs: -------------------------------------------------------------------------------- 1 | defmodule DropAppTest do 2 | use ExUnit.Case 3 | doctest DropApp 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch14/ex1-difference/test/difference_test.exs: -------------------------------------------------------------------------------- 1 | defmodule DifferenceTest do 2 | use ExUnit.Case 3 | doctest Difference 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch07/ex3-struct-components/test/struct_drop_test.exs: -------------------------------------------------------------------------------- 1 | defmodule StructDropTest do 2 | use ExUnit.Case 3 | doctest StructDrop 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch09/ex2-recursion/lib/bounce.ex: -------------------------------------------------------------------------------- 1 | defmodule Bounce do 2 | def report do 3 | receive do 4 | msg -> IO.puts("Received #{msg}") 5 | report() 6 | end 7 | end 8 | end 9 | 10 | -------------------------------------------------------------------------------- /2nd-edition/ch09/ex5-division/lib/bounce.ex: -------------------------------------------------------------------------------- 1 | defmodule Bounce do 2 | def report do 3 | receive do 4 | x -> IO.puts("Divided to #{x / 2}") 5 | report() 6 | end 7 | end 8 | end 9 | 10 | -------------------------------------------------------------------------------- /2nd-edition/ch12/ex5-ets/test/planemo_storage_test.exs: -------------------------------------------------------------------------------- 1 | defmodule PlanemoStorageTest do 2 | use ExUnit.Case 3 | doctest PlanemoStorage 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch12/ex6-ets/test/planemo_storage_test.exs: -------------------------------------------------------------------------------- 1 | defmodule PlanemoStorageTest do 2 | use ExUnit.Case 3 | doctest PlanemoStorage 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch15/fall/web/controllers/page_controller.ex: -------------------------------------------------------------------------------- 1 | defmodule Fall.PageController do 2 | use Fall.Web, :controller 3 | 4 | def index(conn, _params) do 5 | render conn, "index.html" 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /1st-edition/ch04/ex9-factorial-down/fact.ex: -------------------------------------------------------------------------------- 1 | defmodule Fact do 2 | 3 | def factorial(n) when n > 1 do 4 | n * factorial(n-1) 5 | end 6 | 7 | def factorial(n) when n<=1 do 8 | 1 9 | end 10 | end -------------------------------------------------------------------------------- /1st-edition/ch09/ex3-counter/bounce.ex: -------------------------------------------------------------------------------- 1 | defmodule Bounce do 2 | def report(count) do 3 | receive do 4 | msg -> IO.puts("Received #{count}: #{msg}") 5 | report(count + 1) 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch04/ex9-factorial-down/lib/fact.ex: -------------------------------------------------------------------------------- 1 | defmodule Fact do 2 | 3 | def factorial(n) when n > 1 do 4 | n * factorial(n-1) 5 | end 6 | 7 | def factorial(n) when n <= 1 do 8 | 1 9 | end 10 | end -------------------------------------------------------------------------------- /1st-edition/ch13/ex4-unless/logic.ex: -------------------------------------------------------------------------------- 1 | defmodule Logic do 2 | 3 | defmacro unless(condition, options) do 4 | quote do 5 | if(!unquote(condition), unquote(options)) 6 | end 7 | end 8 | 9 | end 10 | 11 | -------------------------------------------------------------------------------- /2nd-edition/ch14/ex4-unless/lib/logic.ex: -------------------------------------------------------------------------------- 1 | defmodule Logic do 2 | 3 | defmacro unless(condition, options) do 4 | quote do 5 | if(!unquote(condition), unquote(options)) 6 | end 7 | end 8 | 9 | end 10 | 11 | -------------------------------------------------------------------------------- /1st-edition/ch09/ex4-state/bounce.ex: -------------------------------------------------------------------------------- 1 | defmodule Bounce do 2 | def report(count) do 3 | new_count = receive do 4 | msg -> IO.puts("Received #{count}: #{msg}") 5 | count + 1 6 | end 7 | report(new_count) 8 | end 9 | end -------------------------------------------------------------------------------- /2nd-edition/ch02/ex7-docs/lib/combined.ex: -------------------------------------------------------------------------------- 1 | # convenience functions! 2 | defmodule Combined do 3 | def height_to_mph(meters) do #takes meters, returns miles per hour 4 | Convert.mps_to_mph(Drop.fall_velocity(meters)) 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /2nd-edition/ch04/ex6-broken/lib/broken.ex: -------------------------------------------------------------------------------- 1 | defmodule Broken do 2 | 3 | def bad_cond(test_val) do 4 | 5 | cond do 6 | test_val < 0 -> x=1 7 | test_val >= 0 -> y=2 8 | end 9 | 10 | x+y 11 | 12 | end 13 | end -------------------------------------------------------------------------------- /2nd-edition/ch09/ex3-counter/lib/bounce.ex: -------------------------------------------------------------------------------- 1 | defmodule Bounce do 2 | def report(count) do 3 | receive do 4 | msg -> IO.puts("Received #{count}: #{msg}") 5 | report(count + 1) 6 | end 7 | end 8 | end 9 | 10 | -------------------------------------------------------------------------------- /1st-edition/ch04/ex6-broken/broken.ex: -------------------------------------------------------------------------------- 1 | defmodule Broken do 2 | 3 | def bad_cond(test_val) do 4 | 5 | cond do 6 | test_val < 0 -> x=1 7 | test_val >= 0 -> y=2 8 | end 9 | 10 | x+y 11 | 12 | end 13 | end -------------------------------------------------------------------------------- /2nd-edition/builder.pl: -------------------------------------------------------------------------------- 1 | use File::Find; 2 | 3 | find(\&wanted, '.'); 4 | 5 | sub wanted 6 | { 7 | if ($_ eq 'mix.exs') 8 | { 9 | print($File::Find::dir, "\n"); 10 | system('mix compile'); 11 | } 12 | } 13 | 14 | -------------------------------------------------------------------------------- /1st-edition/ch07/ex2-struct-match/structs.ex: -------------------------------------------------------------------------------- 1 | defmodule Planemo do 2 | defstruct name: :nil, gravity: 0, diameter: 0, distance_from_sun: 0 3 | end 4 | 5 | defmodule Tower do 6 | defstruct location: "", height: 20, planemo: :earth, name: "" 7 | end 8 | -------------------------------------------------------------------------------- /1st-edition/ch07/ex4-struct-multi/structs.ex: -------------------------------------------------------------------------------- 1 | defmodule Planemo do 2 | defstruct name: :nil, gravity: 0, diameter: 0, distance_from_sun: 0 3 | end 4 | 5 | defmodule Tower do 6 | defstruct location: "", height: 20, planemo: :earth, name: "" 7 | end 8 | -------------------------------------------------------------------------------- /1st-edition/ch07/ex3-struct-components/structs.ex: -------------------------------------------------------------------------------- 1 | defmodule Planemo do 2 | defstruct name: :nil, gravity: 0, diameter: 0, distance_from_sun: 0 3 | end 4 | 5 | defmodule Tower do 6 | defstruct location: "", height: 20, planemo: :earth, name: "" 7 | end 8 | -------------------------------------------------------------------------------- /1st-edition/ch12/ex3-drop-app/drop_app/lib/drop_app.ex: -------------------------------------------------------------------------------- 1 | defmodule DropApp do 2 | use Application 3 | 4 | def start(_type, _args) do 5 | IO.puts("Starting the app...") # show that app is really starting. 6 | DropSup.start_link() 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /1st-edition/ch04/ex7-countdown/count.ex: -------------------------------------------------------------------------------- 1 | defmodule Count do 2 | 3 | def countdown(from) when from > 0 do 4 | IO.puts(from) 5 | countdown(from-1) 6 | end 7 | 8 | def countdown(from) do 9 | IO.puts("blastoff!") 10 | end 11 | 12 | end -------------------------------------------------------------------------------- /1st-edition/ch12/ex3-drop-app2/drop_app/lib/drop_app.ex: -------------------------------------------------------------------------------- 1 | defmodule DropApp do 2 | use Application 3 | 4 | def start(_type, _args) do 5 | IO.puts("Starting the app...") # show that app is really starting. 6 | DropSup.start_link() 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch09/ex4-state/lib/bounce.ex: -------------------------------------------------------------------------------- 1 | defmodule Bounce do 2 | def report(count) do 3 | new_count = receive do 4 | msg -> IO.puts("Received #{count}: #{msg}") 5 | count + 1 6 | end 7 | report(new_count) 8 | end 9 | end 10 | 11 | -------------------------------------------------------------------------------- /2nd-edition/ch15/fall/priv/static/robots.txt: -------------------------------------------------------------------------------- 1 | # See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file 2 | # 3 | # To ban all spiders from the entire site uncomment the next two lines: 4 | # User-agent: * 5 | # Disallow: / 6 | -------------------------------------------------------------------------------- /1st-edition/ch05/ex1-ask/ask.ex: -------------------------------------------------------------------------------- 1 | defmodule Ask do 2 | 3 | def chars() do 4 | IO.puts( 5 | """ 6 | Which planemo are you on? 7 | 1. Earth 8 | 2. Moon 9 | 3. Mars 10 | """ 11 | ) 12 | 13 | IO.getn("Which? > ") 14 | 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /1st-edition/ch13/ex1-difference/difference.ex: -------------------------------------------------------------------------------- 1 | defmodule Difference do 2 | 3 | defmacro m_test(x) do 4 | IO.puts("#{inspect(x)}") 5 | x 6 | end 7 | 8 | def f_test(x) do 9 | IO.puts("#{inspect(x)}") 10 | x 11 | end 12 | 13 | end 14 | -------------------------------------------------------------------------------- /2nd-edition/ch05/ex1-ask/lib/ask.ex: -------------------------------------------------------------------------------- 1 | defmodule Ask do 2 | 3 | def chars() do 4 | IO.puts(""" 5 | Which planemo are you on? 6 | 1. Earth 7 | 2. Moon 8 | 3. Mars 9 | """) 10 | 11 | IO.getn("Which? > ") 12 | 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /2nd-edition/ch14/ex1-difference/lib/difference.ex: -------------------------------------------------------------------------------- 1 | defmodule Difference do 2 | 3 | defmacro m_test(x) do 4 | IO.puts("#{inspect(x)}") 5 | x 6 | end 7 | 8 | def f_test(x) do 9 | IO.puts("#{inspect(x)}") 10 | x 11 | end 12 | end 13 | 14 | -------------------------------------------------------------------------------- /1st-edition/ch11/ex5-ets/planemo_storage.ex: -------------------------------------------------------------------------------- 1 | defmodule PlanemoStorage do 2 | require Planemo 3 | 4 | def setup do 5 | planemo_table = :ets.new(:planemos,[:named_table, 6 | {:keypos, Planemo.planemo(:name) + 1}]) 7 | :ets.info planemo_table 8 | end 9 | end -------------------------------------------------------------------------------- /2nd-edition/ch04/ex7-countdown/lib/count.ex: -------------------------------------------------------------------------------- 1 | defmodule Count do 2 | 3 | def countdown(from) when from > 0 do 4 | IO.inspect(from) 5 | countdown(from-1) 6 | end 7 | 8 | def countdown(from) do 9 | IO.puts("blastoff!") 10 | end 11 | 12 | end 13 | -------------------------------------------------------------------------------- /2nd-edition/ch13/ex3-drop-app/drop_app/lib/drop_app.ex: -------------------------------------------------------------------------------- 1 | defmodule DropApp do 2 | use Application 3 | 4 | def start(_type, _args) do 5 | IO.puts("Starting the app...") # show that app si really starting. 6 | DropSup.start_link() 7 | end 8 | end 9 | 10 | -------------------------------------------------------------------------------- /2nd-edition/ch15/fall/priv/static/js/app.js: -------------------------------------------------------------------------------- 1 | // for phoenix_html support, including form and button helpers 2 | // copy the following scripts into your javascript bundle: 3 | // * https://raw.githubusercontent.com/phoenixframework/phoenix_html/v2.3.0/priv/static/phoenix_html.js -------------------------------------------------------------------------------- /1st-edition/ch07/ex5-protocol/tower.ex: -------------------------------------------------------------------------------- 1 | defmodule Tower do 2 | defstruct location: "", height: 20, planemo: :earth, name: "" 3 | end 4 | 5 | defimpl Valid, for: Tower do 6 | def valid?(%Tower{height: h, planemo: p}) do 7 | h >= 0 && p != nil 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /1st-edition/ch07/ex6-protocol/tower.ex: -------------------------------------------------------------------------------- 1 | defmodule Tower do 2 | defstruct location: "", height: 20, planemo: :earth, name: "" 3 | end 4 | 5 | defimpl Valid, for: Tower do 6 | def valid?(%Tower{height: h, planemo: p}) do 7 | h >= 0 && p != nil 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /1st-edition/ch11/ex9-qlc/test.ex: -------------------------------------------------------------------------------- 1 | defmodule Test do 2 | 3 | def setup do 4 | :mnesia.start() 5 | :mnesia.transaction( 6 | fn() -> 7 | :qlc.e( 8 | :qlc.q( lc x inlist :mnesia.table(planemo), do: x ) 9 | ) end ) 10 | end 11 | end 12 | 13 | 14 | -------------------------------------------------------------------------------- /2nd-edition/ch15/fall/test/controllers/page_controller_test.exs: -------------------------------------------------------------------------------- 1 | defmodule Fall.PageControllerTest do 2 | use Fall.ConnCase 3 | 4 | test "GET /", %{conn: conn} do 5 | conn = get conn, "/" 6 | assert html_response(conn, 200) =~ "Welcome to Phoenix!" 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /2nd-edition/ch07/ex6-protocol/lib/tower.ex: -------------------------------------------------------------------------------- 1 | defmodule Tower do 2 | defstruct location: "", height: 20, planemo: :earth, name: "" 3 | end 4 | 5 | defimpl Valid, for: Tower do 6 | def valid?(%Tower{height: h, planemo: p}) do 7 | h >= 0 && p != nil 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /1st-edition/ch09/ex4-testing/drop.ex: -------------------------------------------------------------------------------- 1 | defmodule Drop do 2 | def fall_velocity(planemo, distance) do 3 | gravity = case planemo do 4 | :earth -> 9.8 5 | :moon -> 1.6 6 | :mars -> 3.71 7 | end 8 | :math.sqrt(2 * gravity * distance) 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /1st-edition/ch10/ex4-testing/drop.ex: -------------------------------------------------------------------------------- 1 | defmodule Drop do 2 | def fall_velocity(planemo, distance) do 3 | gravity = case planemo do 4 | :earth -> 9.8 5 | :moon -> 1.6 6 | :mars -> 3.71 7 | end 8 | :math.sqrt(2 * gravity * distance) 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /2nd-edition/ch12/ex5-ets/lib/planemo_storage.ex: -------------------------------------------------------------------------------- 1 | defmodule PlanemoStorage do 2 | require Planemo 3 | 4 | def setup do 5 | planemo_table = :ets.new(:planemos,[:named_table, 6 | {:keypos, Planemo.planemo(:name) + 1}]) 7 | :ets.info planemo_table 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /1st-edition/ch09/ex4-testing/drop_bad.ex: -------------------------------------------------------------------------------- 1 | defmodule Drop do 2 | def fall_velocity(planemo, distance) do 3 | gravity = case planemo do 4 | :earth -> 9.8 5 | :moon -> 1.6 6 | :mars -> 3.41 7 | end 8 | :math.sqrt(2 * gravity * distance) 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /1st-edition/ch10/ex4-testing/drop_bad.ex: -------------------------------------------------------------------------------- 1 | defmodule Drop do 2 | def fall_velocity(planemo, distance) do 3 | gravity = case planemo do 4 | :earth -> 9.8 5 | :moon -> 1.6 6 | :mars -> 3.41 7 | end 8 | :math.sqrt(2 * gravity * distance) 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /2nd-edition/ch04/ex1-case/xbuild/dev/lib/drop/ebin/drop.app: -------------------------------------------------------------------------------- 1 | {application,drop, 2 | [{registered,[]}, 3 | {description,"drop"}, 4 | {vsn,"0.1.0"}, 5 | {modules,['Elixir.Drop']}, 6 | {applications,[kernel,stdlib,elixir,logger]}]}. -------------------------------------------------------------------------------- /2nd-edition/ch11/ex4a-testing/lib/drop.ex: -------------------------------------------------------------------------------- 1 | defmodule Drop do 2 | def fall_velocity(planemo, distance) do 3 | gravity = case planemo do 4 | :earth -> 9.8 5 | :moon -> 1.6 6 | :mars -> 3.71 7 | end 8 | :math.sqrt(2 * gravity * distance) 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /1st-edition/ch13/ex5-programmatic/function_maker.ex: -------------------------------------------------------------------------------- 1 | defmodule FunctionMaker do 2 | defmacro create_multiplier(function_name, factor) do 3 | quote do 4 | def unquote(function_name)(value) do 5 | unquote(factor) * value 6 | end 7 | end 8 | end 9 | end 10 | 11 | -------------------------------------------------------------------------------- /2nd-edition/ch11/ex5-setup/lib/drop.ex: -------------------------------------------------------------------------------- 1 | defmodule Drop do 2 | def fall_velocity(planemo, distance) do 3 | gravity = case planemo do 4 | :earth -> 9.8 5 | :moon -> 1.6 6 | :mars -> 3.71 7 | end 8 | :math.sqrt(2 * gravity * distance) 9 | end 10 | end 11 | 12 | -------------------------------------------------------------------------------- /2nd-edition/ch02/ex1-drop/lib/drop.ex: -------------------------------------------------------------------------------- 1 | defmodule Drop do 2 | def fall_velocity(distance) do 3 | :math.sqrt(2 * 9.8 * distance) 4 | end 5 | 6 | def mps_to_mph(mps) do 7 | 2.23693629 * mps 8 | end 9 | 10 | def mps_to_kph(mps) do 11 | 3.6 * mps 12 | end 13 | 14 | end 15 | -------------------------------------------------------------------------------- /2nd-edition/ch11/ex4-testing/lib/drop_bad.ex: -------------------------------------------------------------------------------- 1 | defmodule Drop do 2 | def fall_velocity(planemo, distance) do 3 | gravity = case planemo do 4 | :earth -> 9.8 5 | :moon -> 1.6 6 | :mars -> 3.41 7 | end 8 | :math.sqrt(2 * gravity * distance) 9 | end 10 | end 11 | 12 | -------------------------------------------------------------------------------- /2nd-edition/ch11/ex4-testing/lib/drop_good.ee: -------------------------------------------------------------------------------- 1 | defmodule Drop do 2 | def fall_velocity(planemo, distance) do 3 | gravity = case planemo do 4 | :earth -> 9.8 5 | :moon -> 1.6 6 | :mars -> 3.71 7 | end 8 | :math.sqrt(2 * gravity * distance) 9 | end 10 | end 11 | 12 | -------------------------------------------------------------------------------- /2nd-edition/ch14/ex5-programmatic/lib/function_maker.ex: -------------------------------------------------------------------------------- 1 | defmodule FunctionMaker do 2 | defmacro create_multiplier(function_name, factor) do 3 | quote do 4 | def unquote(function_name)(value) do 5 | unquote(factor) * value 6 | end 7 | end 8 | end 9 | end 10 | 11 | -------------------------------------------------------------------------------- /1st-edition/ch02/ex1-drop/drop.ex: -------------------------------------------------------------------------------- 1 | defmodule Drop do 2 | def fall_velocity(distance) do 3 | :math.sqrt(2 * 9.8 * distance) 4 | end 5 | 6 | def mps_to_mph(mps) do 7 | 2.23693629 * mps 8 | end 9 | 10 | def mps_to_kph(mps) do 11 | 3.6 * mps 12 | end 13 | 14 | end 15 | 16 | 17 | -------------------------------------------------------------------------------- /1st-edition/ch04/ex2-case/drop.ex: -------------------------------------------------------------------------------- 1 | defmodule Drop do 2 | 3 | def fall_velocity(planemo, distance) when distance >= 0 do 4 | gravity = case planemo do 5 | :earth -> 9.8 6 | :moon -> 1.6 7 | :mars -> 3.71 8 | end 9 | :math.sqrt(2 * gravity * distance) 10 | end 11 | 12 | end -------------------------------------------------------------------------------- /1st-edition/ch05/ex2-ask/drop.ex: -------------------------------------------------------------------------------- 1 | defmodule Drop do 2 | 3 | def fall_velocity(planemo, distance) when distance >= 0 do 4 | gravity = case planemo do 5 | :earth -> 9.8 6 | :moon -> 1.6 7 | :mars -> 3.71 8 | end 9 | :math.sqrt(2 * gravity * distance) 10 | end 11 | 12 | end -------------------------------------------------------------------------------- /1st-edition/ch07/ex5-protocol/planemo.ex: -------------------------------------------------------------------------------- 1 | defmodule Planemo do 2 | defstruct name: :nil, gravity: 0, diameter: 0, distance_from_sun: 0 3 | end 4 | 5 | defimpl Valid, for: Planemo do 6 | def valid?(p) do 7 | p.gravity >= 0 && p.diameter >= 0 && 8 | p.distance_from_sun >= 0 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /1st-edition/ch07/ex6-protocol/planemo.ex: -------------------------------------------------------------------------------- 1 | defmodule Planemo do 2 | defstruct name: :nil, gravity: 0, diameter: 0, distance_from_sun: 0 3 | end 4 | 5 | defimpl Valid, for: Planemo do 6 | def valid?(p) do 7 | p.gravity >= 0 && p.diameter >= 0 && 8 | p.distance_from_sun >= 0 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /1st-edition/ch07/ex7-inspect/planemo.ex: -------------------------------------------------------------------------------- 1 | defmodule Planemo do 2 | defstruct name: :nil, gravity: 0, diameter: 0, distance_from_sun: 0 3 | end 4 | 5 | defimpl Valid, for: Planemo do 6 | def valid?(p) do 7 | p.gravity >= 0 && p.diameter >= 0 && 8 | p.distance_from_sun >= 0 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /2nd-edition/ch04/ex2-case/lib/drop.ex: -------------------------------------------------------------------------------- 1 | defmodule Drop do 2 | 3 | def fall_velocity(planemo, distance) when distance >= 0 do 4 | gravity = case planemo do 5 | :earth -> 9.8 6 | :moon -> 1.6 7 | :mars -> 3.71 8 | end 9 | :math.sqrt(2 * gravity * distance) 10 | end 11 | 12 | end -------------------------------------------------------------------------------- /2nd-edition/ch07/ex5-protocol/lib/planemo.ex: -------------------------------------------------------------------------------- 1 | defmodule Planemo do 2 | defstruct name: :nil, gravity: 0, diameter: 0, distance_from_sun: 0 3 | end 4 | 5 | defimpl Valid, for: Planemo do 6 | def valid?(p) do 7 | p.gravity >= 0 && p.diameter >= 0 && 8 | p.distance_from_sun >= 0 9 | end 10 | end -------------------------------------------------------------------------------- /2nd-edition/ch07/ex6-protocol/lib/planemo.ex: -------------------------------------------------------------------------------- 1 | defmodule Planemo do 2 | defstruct name: :nil, gravity: 0, diameter: 0, distance_from_sun: 0 3 | end 4 | 5 | defimpl Valid, for: Planemo do 6 | def valid?(p) do 7 | p.gravity >= 0 && p.diameter >= 0 && 8 | p.distance_from_sun >= 0 9 | end 10 | end -------------------------------------------------------------------------------- /2nd-edition/ch07/ex7-inspect/lib/planemo.ex: -------------------------------------------------------------------------------- 1 | defmodule Planemo do 2 | defstruct name: :nil, gravity: 0, diameter: 0, distance_from_sun: 0 3 | end 4 | 5 | defimpl Valid, for: Planemo do 6 | def valid?(p) do 7 | p.gravity >= 0 && p.diameter >= 0 && 8 | p.distance_from_sun >= 0 9 | end 10 | end -------------------------------------------------------------------------------- /2nd-edition/ch15/fall/web/templates/fall/welcome.html.eex: -------------------------------------------------------------------------------- 1 |
Fall again?
4 | 5 | <%= form_for @conn, fall_path(@conn, :faller), [as: :calculation], 6 | fn f-> %> 7 | <%= select f, :planemo, @choices %> 8 | <%= text_input f, :distance %> 9 | <%= submit "Calculate" %> 10 | <% end %> 11 | 12 | -------------------------------------------------------------------------------- /2nd-edition/ch10/ex1-tryCatch/lib/drop.ex: -------------------------------------------------------------------------------- 1 | defmodule Drop do 2 | def fall_velocity(planemo, distance) do 3 | gravity = case planemo do 4 | :earth -> 9.8 5 | :moon -> 1.6 6 | :mars -> 3.71 7 | end 8 | try do 9 | :math.sqrt(2 * gravity * distance) 10 | rescue 11 | error -> error 12 | end 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /2nd-edition/ch11/ex4-testing/test/drop_test.exs: -------------------------------------------------------------------------------- 1 | defmodule DropTest do 2 | use ExUnit.Case, async: true 3 | 4 | test "Zero distance gives zero velocity" do 5 | assert Drop.fall_velocity(:earth,0) == 0 6 | end 7 | 8 | test "Mars calculation correct" do 9 | assert Drop.fall_velocity(:mars, 10) == :math.sqrt(2 * 3.71 * 10) 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /2nd-edition/ch12/ex1-records/lib/records.ex: -------------------------------------------------------------------------------- 1 | defmodule Planemo do 2 | require Record 3 | Record.defrecord :planemo, [name: :nil, gravity: 0, diameter: 0, 4 | distance_from_sun: 0] 5 | end 6 | 7 | defmodule Tower do 8 | require Record 9 | Record.defrecord :tower, Tower, 10 | [location: "", height: 20, planemo: :earth, name: ""] 11 | end 12 | 13 | -------------------------------------------------------------------------------- /2nd-edition/ch12/ex2-records/lib/records.ex: -------------------------------------------------------------------------------- 1 | defmodule Planemo do 2 | require Record 3 | Record.defrecord :planemo, [name: :nil, gravity: 0, diameter: 0, 4 | distance_from_sun: 0] 5 | end 6 | 7 | defmodule Tower do 8 | require Record 9 | Record.defrecord :tower, Tower, 10 | [location: "", height: 20, planemo: :earth, name: ""] 11 | end 12 | 13 | -------------------------------------------------------------------------------- /2nd-edition/ch12/ex3-records/lib/records.ex: -------------------------------------------------------------------------------- 1 | defmodule Planemo do 2 | require Record 3 | Record.defrecord :planemo, [name: :nil, gravity: 0, diameter: 0, 4 | distance_from_sun: 0] 5 | end 6 | 7 | defmodule Tower do 8 | require Record 9 | Record.defrecord :tower, Tower, 10 | [location: "", height: 20, planemo: :earth, name: ""] 11 | end 12 | 13 | -------------------------------------------------------------------------------- /2nd-edition/ch12/ex4-records/lib/records.ex: -------------------------------------------------------------------------------- 1 | defmodule Planemo do 2 | require Record 3 | Record.defrecord :planemo, [name: :nil, gravity: 0, diameter: 0, 4 | distance_from_sun: 0] 5 | end 6 | 7 | defmodule Tower do 8 | require Record 9 | Record.defrecord :tower, Tower, 10 | [location: "", height: 20, planemo: :earth, name: ""] 11 | end 12 | 13 | -------------------------------------------------------------------------------- /2nd-edition/ch12/ex5-ets/lib/records.ex: -------------------------------------------------------------------------------- 1 | defmodule Planemo do 2 | require Record 3 | Record.defrecord :planemo, [name: :nil, gravity: 0, diameter: 0, 4 | distance_from_sun: 0] 5 | end 6 | 7 | defmodule Tower do 8 | require Record 9 | Record.defrecord :tower, Tower, 10 | [location: "", height: 20, planemo: :earth, name: ""] 11 | end 12 | 13 | -------------------------------------------------------------------------------- /2nd-edition/ch12/ex6-ets/lib/records.ex: -------------------------------------------------------------------------------- 1 | defmodule Planemo do 2 | require Record 3 | Record.defrecord :planemo, [name: :nil, gravity: 0, diameter: 0, 4 | distance_from_sun: 0] 5 | end 6 | 7 | defmodule Tower do 8 | require Record 9 | Record.defrecord :tower, Tower, 10 | [location: "", height: 20, planemo: :earth, name: ""] 11 | end 12 | 13 | -------------------------------------------------------------------------------- /2nd-edition/ch12/ex8-mnesia/lib/records.ex: -------------------------------------------------------------------------------- 1 | defmodule Planemo do 2 | require Record 3 | Record.defrecord :planemo, [name: :nil, gravity: 0, diameter: 0, 4 | distance_from_sun: 0] 5 | end 6 | 7 | defmodule Tower do 8 | require Record 9 | Record.defrecord :tower, Tower, 10 | [location: "", height: 20, planemo: :earth, name: ""] 11 | end 12 | 13 | -------------------------------------------------------------------------------- /1st-edition/ch03/ex1-atoms/drop.ex: -------------------------------------------------------------------------------- 1 | defmodule Drop do 2 | 3 | def fall_velocity(:earth, distance) do 4 | :math.sqrt(2 * 9.8 * distance) 5 | end 6 | 7 | def fall_velocity(:moon, distance) do 8 | :math.sqrt(2 * 1.6 * distance) 9 | end 10 | 11 | def fall_velocity(:mars, distance) do 12 | :math.sqrt(2 * 3.71 * distance) 13 | end 14 | 15 | end -------------------------------------------------------------------------------- /1st-edition/ch10/ex1-tryCatch/drop2.ex: -------------------------------------------------------------------------------- 1 | defmodule Drop do 2 | def fall_velocity(planemo, distance) do 3 | try do 4 | gravity = case planemo do 5 | :earth -> 9.8 6 | :moon -> 1.6 7 | :mars -> 3.71 8 | end 9 | :math.sqrt(2 * gravity * distance) 10 | rescue 11 | _error -> _error 12 | end 13 | end 14 | end -------------------------------------------------------------------------------- /2nd-edition/ch10/ex1a-tryCatch/lib/drop.ex: -------------------------------------------------------------------------------- 1 | defmodule Drop do 2 | def fall_velocity(planemo, distance) do 3 | try do 4 | gravity = case planemo do 5 | :earth -> 9.8 6 | :moon -> 1.6 7 | :mars -> 3.71 8 | end 9 | :math.sqrt(2 * gravity * distance) 10 | rescue 11 | error -> error 12 | end 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /2nd-edition/ch12/ex7-ets-calculator/lib/records.ex: -------------------------------------------------------------------------------- 1 | defmodule Planemo do 2 | require Record 3 | Record.defrecord :planemo, [name: :nil, gravity: 0, diameter: 0, 4 | distance_from_sun: 0] 5 | end 6 | 7 | defmodule Tower do 8 | require Record 9 | Record.defrecord :tower, Tower, 10 | [location: "", height: 20, planemo: :earth, name: ""] 11 | end 12 | 13 | -------------------------------------------------------------------------------- /1st-edition/appB/ex1-docs/combined/mix.lock: -------------------------------------------------------------------------------- 1 | %{"ex_doc": {:git, "git://github.com/elixir-lang/ex_doc.git", "ca71b84b9c3c7e23b4b661e485a909aee3fdbc3b", []}, 2 | "hoedown": {:git, "git://github.com/hoedown/hoedown.git", "0610117f44b173a4e2112afb2f510156a32355b5", []}, 3 | "markdown": {:git, "git://github.com/devinus/markdown.git", "0345e2044ba71780ba02b2591f1017703d0fa148", []}} 4 | -------------------------------------------------------------------------------- /2nd-edition/ch14/ex6-multidrop/lib/function_maker.ex: -------------------------------------------------------------------------------- 1 | defmodule FunctionMaker do 2 | defmacro create_functions(planemo_list) do 3 | Enum.map planemo_list, fn{name, gravity} -> 4 | quote do 5 | def unquote(:"#{name}_drop")(distance) do 6 | :math.sqrt(2 * unquote(gravity) * distance) 7 | end 8 | end 9 | end 10 | end 11 | end 12 | 13 | -------------------------------------------------------------------------------- /1st-edition/ch13/ex6-multidrop/function_maker.ex: -------------------------------------------------------------------------------- 1 | defmodule FunctionMaker do 2 | defmacro create_functions(planemo_list) do 3 | Enum.map planemo_list, fn {name, gravity} -> 4 | quote do 5 | def unquote(:"#{name}_drop")(distance) do 6 | :math.sqrt(2 * unquote(gravity) * distance) 7 | end 8 | end 9 | end 10 | end 11 | end 12 | 13 | -------------------------------------------------------------------------------- /2nd-edition/ch06/ex1-product/lib/overall.ex: -------------------------------------------------------------------------------- 1 | defmodule Overall do 2 | def product([]) do 3 | 0 4 | end 5 | 6 | def product(list) do 7 | product(list, 1) 8 | end 9 | 10 | def product([], accumulated_product) do 11 | accumulated_product 12 | end 13 | 14 | def product([head | tail], accumulated_product) do 15 | product(tail, head * accumulated_product) 16 | end 17 | end -------------------------------------------------------------------------------- /1st-edition/ch04/ex10-factorial-down-instrumented/fact.ex: -------------------------------------------------------------------------------- 1 | defmodule Fact do 2 | 3 | def factorial(n) when n > 1 do 4 | IO.puts("Calling from #{n}.") 5 | result = n * factorial(n-1) 6 | IO.puts("#{n} yields #{result}.") 7 | result 8 | end 9 | 10 | def factorial(n) when n<=1 do 11 | IO.puts("Calling from 1.") 12 | IO.puts("1 yields 1.") 13 | 1 14 | end 15 | end -------------------------------------------------------------------------------- /1st-edition/ch09/ex4-testing/drop_test.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start 2 | 3 | defmodule DropTest do 4 | use ExUnit.Case, async: true 5 | 6 | test "Zero distance gives zero velocity" do 7 | assert Drop.fall_velocity(:earth,0) == 0 8 | end 9 | 10 | test "Mars calculation correct" do 11 | assert Drop.fall_velocity(:mars, 10) == :math.sqrt(2 * 3.71 * 10) 12 | end 13 | end 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /1st-edition/ch10/ex4-testing/drop_test.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start 2 | 3 | defmodule DropTest do 4 | use ExUnit.Case, async: true 5 | 6 | test "Zero distance gives zero velocity" do 7 | assert Drop.fall_velocity(:earth,0) == 0 8 | end 9 | 10 | test "Mars calculation correct" do 11 | assert Drop.fall_velocity(:mars, 10) == :math.sqrt(2 * 3.71 * 10) 12 | end 13 | end 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /2nd-edition/ch04/ex10-factorial-down-instrumented/lib/fact.ex: -------------------------------------------------------------------------------- 1 | defmodule Fact do 2 | 3 | def factorial(n) when n > 1 do 4 | IO.puts("Calling from #{n}.") 5 | result = n * factorial(n - 1) 6 | IO.puts("#{n} yields #{result}.") 7 | result 8 | end 9 | 10 | def factorial(n) when n <= 1 do 11 | IO.puts("Calling from 1.") 12 | IO.puts("1 yields 1.") 13 | 1 14 | end 15 | end -------------------------------------------------------------------------------- /2nd-edition/ch11/dia_test/lib/dia_test.ex: -------------------------------------------------------------------------------- 1 | defmodule DiaTest do 2 | 3 | @spec manipulate({atom(), number()}) :: number() 4 | def manipulate({op, n}) do 5 | if op == :add do 6 | n + 1 7 | else 8 | n - 1 9 | end 10 | end 11 | 12 | def calculate() do 13 | x = manipulate({:add, 3}) 14 | y = manipulate({4, :sub}) 15 | IO.puts("Values #{x}, #{y}.") 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /1st-edition/ch06/ex1-product/overall.ex: -------------------------------------------------------------------------------- 1 | defmodule Overall do 2 | def product([]) do 3 | 0 4 | end 5 | 6 | def product(list) do 7 | product(list, 1) 8 | end 9 | 10 | def product([], accumulated_product) do 11 | accumulated_product 12 | end 13 | 14 | def product([head | tail], accumulated_product) do 15 | product(tail, head * accumulated_product) 16 | end 17 | end 18 | 19 | -------------------------------------------------------------------------------- /2nd-edition/ch12/tower_definitions.txt: -------------------------------------------------------------------------------- 1 | require Tower 2 | tower1 = Tower.tower() 3 | tower2 = Tower.tower(location: "Grand Canyon") 4 | tower3 = Tower.tower(location: "NYC", height: 241, name: "Woolworth Building") 5 | tower4 = Tower.tower location: "Rupes Altat 241", height: 500, planemo: :moon, name: "Piccolini View" 6 | tower5 = Tower.tower planemo: :mars, height: 500, name: "Daga Vallis", location: "Valles Marineris" 7 | -------------------------------------------------------------------------------- /1st-edition/appB/ex1-docs/docs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |