From 0e31a9daebe7d53921023d853a603882e2c98b77 Mon Sep 17 00:00:00 2001 From: Colin Jones Date: Wed, 3 May 2017 15:27:23 -0500 Subject: [PATCH 1/6] Modernize & simplify README --- README.md | 71 +++++++++++++++++++++---------------------------------- 1 file changed, 27 insertions(+), 44 deletions(-) diff --git a/README.md b/README.md index 55ec748..50866aa 100644 --- a/README.md +++ b/README.md @@ -7,22 +7,15 @@ making tests pass! ## Getting Started -The easiest and fastest way to get the koans up and running is to [download the -latest zip file from Github](https://github.com/functional-koans/clojure-koans/releases). -This way, you'll have all the dependencies you need, including Clojure itself -and JLine, and you can skip the rest of this section (skip to "Running the -Koans"). - -If you're starting from a cloned or forked repo, that's cool too. This way -you'll be able to track your progress in Git, and see how your answers compare -to others, by checking out the project's Network tab. You might want to create -your own branch - that way if you pull back the latest koans from master, it'll -be a bit easier to manage the inevitable conflicts if we make changes to -exercises you've already completed. +I recommend starting from a cloned or forked repo. This way you'll be able to +track your progress in Git. You might want to create your own branch - that way +if you pull back the latest koans from master, it'll be a bit easier to manage +the inevitable conflicts if we make changes to exercises you've already +completed. You have a few options for installation: -- Install the dependencies for the koans (such as Clojure) on your machine, +- Install the dependencies for the koans (such as Clojure) on your machine - Use Vagrant and the configuration in this repository - Use Docker @@ -33,22 +26,17 @@ Instructions for each option are below! The only things you'll need to run the Clojure Koans are: -- JRE 1.6 or higher -- [clojure-1.8.0.jar](http://repo1.maven.org/maven2/org/clojure/clojure/1.8.0/clojure-1.8.0.zip) +- JDK (I suggest version 8, but anything 6 or above should work fine) +- [Leiningen](http://github.com/technomancy/leiningen), a build tool for Clojure -You can use [Leiningen](http://github.com/technomancy/leiningen) to -automatically install the Clojure jar in the right place. Leiningen will also -get you a couple more jarfiles, including JLine, which allows you some of the -functionality of readline (command-line history, for example). +Once you've cloned this repo and installed the dependencies, you can run: -Dependencies are installed automatically with lein 2, but if for some reason -you're on lein 1 and can't upgrade, you'll need to run +``` +lein repl +``` -`lein deps` - -which will download all dependencies you need to run the Clojure koans. - -I strongly recommend that you upgrade to lein 2 instead! +to make sure all the dependencies get downloaded properly (and then `(exit)` +when you want to quit). See below for details on the REPL. ### Installation with Vagrant @@ -76,7 +64,7 @@ To run koans: docker run --rm -it -v $(pwd):/app -w /app clojure lein koan run ``` -To execute REPL: +To start up a REPL: ``` docker run --rm -it -v $(pwd):/app -w /app clojure lein repl @@ -85,13 +73,7 @@ docker run --rm -it -v $(pwd):/app -w /app clojure lein repl ## Running the Koans -If you're running from the zipfile, simply run - -`script/run` on Mac/\*nix - -`script\run` on Windows - -If you're running from a checkout using lein 2, run the koans via +Run the koans via: `lein koan run` @@ -99,9 +81,9 @@ If want to run directly from a REPL, once you are inside the `lein repl` prompt `(exec "run")` -It's an auto-runner, so as you save your files with the correct answers, it will -advance you to the next koan or file (conveniently, all files are prefixed with -the sequence that you should follow). +Either way, it's an auto-runner, so as you save your files with the correct +answers, it will advance you to the next koan or file (conveniently, all files +are prefixed with the sequence that you should follow). You'll see something like this: @@ -131,14 +113,14 @@ answer is what it is. Enjoy your path to Clojure enlightenment! ## Trying more things out -There's a REPL (Read-Evaluate-Print Loop) included in the Clojure Koans. Just -run: +It's very useful to try things out in a REPL (Read-Evaluate-Print Loop) +whenever you get stuck or curious. Run: -`script/repl` on Mac/\*nix +``` +lein repl +``` -`script\repl` on Windows - -If you're on lein 2, `lein repl` is what you want instead. +and you'll be able to type expressions in, and see what output they produce. Here are some interesting commands you might try, once you're in a running REPL: @@ -157,7 +139,8 @@ And if those still don't make sense: will show you what those commands mean. -You can exit the REPL with `CTRL-d` on any OS. +You can exit the REPL with `CTRL-d`, `(exit)`, or `(quit)`. + ## Contributing From 9b3efbb0268794c6f5e5516589bb17ed78000602 Mon Sep 17 00:00:00 2001 From: Colin Jones Date: Fri, 5 May 2017 07:54:11 -0500 Subject: [PATCH 2/6] Remove presumptuous "easy", "just", "simple" --- README.md | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 50866aa..9bf2765 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,7 @@ # Clojure Koans -The Clojure Koans are a fun and easy way to get started with Clojure - no -experience assumed or required. Just follow the instructions below to start -making tests pass! +The Clojure Koans are a fun way to get started with Clojure - no experience +assumed or required. Follow the instructions below to start making tests pass! ## Getting Started @@ -94,7 +93,7 @@ You'll see something like this: (= __ true) The output is telling you that you have a failing test in the file named -`01_equalities.clj`, on line 3. So you just need to open that file up and make +`01_equalities.clj`, on line 3. So you need to open that file up and make it pass! You'll always be filling in the blanks to make tests pass. Sometimes there could be several correct answers (or even an infinite number): any of them will work in these cases. Some tests will pass even if you replace @@ -103,10 +102,10 @@ you give one correct expression to replace each blank. The koans differ from normal TDD in that the tests are already written for you, so you'll have to pay close attention to the failure messages, because up until -the very end, making a test pass just means that the next failure message comes +the very end, making a test pass means that the next failure message comes up. -While it might be easy (especially at first) to just fill in the blanks making +While it might be easy (especially at first) to fill in the blanks making things pass, you should work thoughtfully, making sure you understand why the answer is what it is. Enjoy your path to Clojure enlightenment! @@ -170,8 +169,8 @@ https://github.com/functional-koans/clojure-koans/contributors These exercises were started by [Aaron Bedra](http://github.com/abedra) of [Relevance, Inc.](http://github.com/relevance) in early 2010, as a learning tool for newcomers to functional programming. Aaron's macro-fu makes these -koans extremely simple and fun to use, and to improve upon, and without -Relevance's initiative, this project would not exist. +koans clear and fun to use and improve upon, and without Relevance's +initiative, this project would not exist. Using the [koans](http://en.wikipedia.org/wiki/koan) metaphor as a tool for learning a programming language started with the From e74a2664f014a3b62a8e8302240ea2fc645a4422 Mon Sep 17 00:00:00 2001 From: Colin Jones Date: Wed, 10 May 2017 08:32:25 -0500 Subject: [PATCH 3/6] Make it clearer what %2 is about --- resources/koans.clj | 4 ++-- src/koans/07_functions.clj | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/resources/koans.clj b/resources/koans.clj index b302af5..f8ab268 100644 --- a/resources/koans.clj +++ b/resources/koans.clj @@ -79,7 +79,7 @@ false "February" 1 "January" - :c 3 + :c 3 2 2010 2014 2018 "PyeongChang" "Sochi" "Vancouver" @@ -90,7 +90,7 @@ 10 60 15 - 30] + "AACC"] "___" [+ * (fn [f] (f 5)) diff --git a/src/koans/07_functions.clj b/src/koans/07_functions.clj index 4bf40a0..4ce01bb 100644 --- a/src/koans/07_functions.clj +++ b/src/koans/07_functions.clj @@ -23,7 +23,7 @@ (= __ (#(+ %1 %2 %3) 4 5 6)) "Arguments can also be skipped" - (= __ (#(* 15 %2) 1 2)) + (= __ (#(str "AA" %2) "bb" "CC")) "One function can beget another" (= 9 (((fn [] ___)) 4 5)) From 7974120ec393f84a9180560a0cfa03429a00712c Mon Sep 17 00:00:00 2001 From: Colin Jones Date: Mon, 9 Oct 2017 13:16:10 -0500 Subject: [PATCH 4/6] Use an explicit function argument for `iterate` Also replace :hello with "hello" to avoid potential confusion since :hello is also a function. refs #75 --- resources/koans.clj | 2 +- src/koans/11_lazy_sequences.clj | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/resources/koans.clj b/resources/koans.clj index f8ab268..a63ec62 100644 --- a/resources/koans.clj +++ b/resources/koans.clj @@ -127,7 +127,7 @@ [0 1 2 3 4] 10 95 - (range 20) + [1 2 4 8 16 32 64 128] :a] "___" [(fn [x] x)]}] diff --git a/src/koans/11_lazy_sequences.clj b/src/koans/11_lazy_sequences.clj index 1023785..5144361 100644 --- a/src/koans/11_lazy_sequences.clj +++ b/src/koans/11_lazy_sequences.clj @@ -17,12 +17,12 @@ (drop __ (range 100))) "Iteration provides an infinite lazy sequence" - (= __ (take 20 (iterate inc 0))) + (= __ (take 8 (iterate (fn [x] (* x 2)) 1))) "Repetition is key" (= [:a :a :a :a :a :a :a :a :a :a] (repeat 10 __)) "Iteration can be used for repetition" - (= (repeat 100 :hello) - (take 100 (iterate ___ :hello)))) + (= (repeat 100 "hello") + (take 100 (iterate ___ "hello")))) From ad5c0e6081b2784947ec38ce9348e33fde88f3c2 Mon Sep 17 00:00:00 2001 From: Colin Jones Date: Tue, 24 Oct 2017 11:13:26 -0500 Subject: [PATCH 5/6] Bump koan-engine to remove old jline --- project.clj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project.clj b/project.clj index 439608d..9638582 100644 --- a/project.clj +++ b/project.clj @@ -1,7 +1,7 @@ (defproject clojure-koans "0.5.1-SNAPSHOT" :description "The Clojure koans." :dependencies [[org.clojure/clojure "1.8.0"] - [koan-engine "0.2.3"]] + [koan-engine "0.2.4"]] :dev-dependencies [[lein-koan "0.1.3"]] :profiles {:dev {:dependencies [[lein-koan "0.1.3"]]}} :repl-options {:init-ns koan-engine.runner From faa02b5faec51f1c18ff403bf0a7ec09414056f4 Mon Sep 17 00:00:00 2001 From: Colin Jones Date: Tue, 24 Oct 2017 11:22:42 -0500 Subject: [PATCH 6/6] Bump lein-koan dependency --- project.clj | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/project.clj b/project.clj index 9638582..e6d15d5 100644 --- a/project.clj +++ b/project.clj @@ -2,9 +2,9 @@ :description "The Clojure koans." :dependencies [[org.clojure/clojure "1.8.0"] [koan-engine "0.2.4"]] - :dev-dependencies [[lein-koan "0.1.3"]] - :profiles {:dev {:dependencies [[lein-koan "0.1.3"]]}} + :dev-dependencies [[lein-koan "0.1.4"]] + :profiles {:dev {:dependencies [[lein-koan "0.1.4"]]}} :repl-options {:init-ns koan-engine.runner :init ^:displace (do (use '[koan-engine.core]))} - :plugins [[lein-koan "0.1.3"]] + :plugins [[lein-koan "0.1.4"]] :main koan-engine.runner/exec)