├── .github
└── FUNDING.yml
├── assets
├── calva-repl-button.png
├── calva-jack-in-aliases.png
├── calva-jack-in-project-types.png
└── exercism-clojure-track-wo-header.png
├── .gitignore
├── .gitpod.Dockerfile
├── .vscode
└── settings.json
├── .gitpod.yml
├── LICENSE
├── README.md
└── INSTRUCTIONS.md
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | github: [PEZ]
--------------------------------------------------------------------------------
/assets/calva-repl-button.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PEZ/clojure-exercism-template/HEAD/assets/calva-repl-button.png
--------------------------------------------------------------------------------
/assets/calva-jack-in-aliases.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PEZ/clojure-exercism-template/HEAD/assets/calva-jack-in-aliases.png
--------------------------------------------------------------------------------
/assets/calva-jack-in-project-types.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PEZ/clojure-exercism-template/HEAD/assets/calva-jack-in-project-types.png
--------------------------------------------------------------------------------
/assets/exercism-clojure-track-wo-header.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PEZ/clojure-exercism-template/HEAD/assets/exercism-clojure-track-wo-header.png
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | pom.xml
2 | pom.xml.asc
3 | *.jar
4 | *.class
5 | /lib/
6 | /classes/
7 | /target/
8 | /checkouts/
9 | .lein-deps-sum
10 | .lein-repl-history
11 | .lein-plugins/
12 | .lein-failures
13 | .nrepl-port
14 | .cpcache/
15 | **/.calva/output-window/output.calva-repl
16 | **/.lsp/sqlite*db
17 | .exercism-config/
18 |
--------------------------------------------------------------------------------
/.gitpod.Dockerfile:
--------------------------------------------------------------------------------
1 | FROM gitpod/workspace-full-vnc
2 |
3 | USER gitpod
4 |
5 | RUN brew install clojure/tools/clojure && \
6 | brew install leiningen && \
7 | brew install exercism && \
8 | clojure -Sdeps '{:deps {nrepl/nrepl {:mvn/version,"0.8.3"},cider/cider-nrepl {:mvn/version,"0.26.0"}}}' -P && \
9 | echo "\n"'# Make JavaFX display windows with visible content'"\n"JAVA_TOOL_OPTIONS=\"\$JAVA_TOOL_OPTIONS -Dsun.java2d.xrender=false\""\n" >> /home/gitpod/.bashrc
10 |
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "workbench.editorAssociations": {
3 | "*.md": "vscode.markdown.preview.editor"
4 | },
5 | "editor.fontSize": 14,
6 | "breadcrumbs.enabled": false,
7 | "editor.minimap.enabled": false,
8 | "calva.prettyPrintingOptions": {
9 | "enabled": true,
10 | "printEngine": "pprint",
11 | "width": 40,
12 | "maxLength": null
13 | },
14 | "markdown.preview.fontSize": 16,
15 | "problems.decorations.enabled": false,
16 | "editor.lightbulb.enabled": false
17 | }
--------------------------------------------------------------------------------
/.gitpod.yml:
--------------------------------------------------------------------------------
1 | image:
2 | file: .gitpod.Dockerfile
3 |
4 | vscode:
5 | extensions:
6 | - betterthantomorrow.calva
7 |
8 | ports:
9 | - port: 5900
10 | onOpen: ignore
11 | - port: 6080
12 | onOpen: ignore
13 |
14 | tasks:
15 | - name: Excercism terminal
16 | command: |
17 | # Persist Exercism config
18 | mkdir -p .exercism-config
19 | WS_DIR=${PWD}
20 | (cd ~/.config && ln -s ${WS_DIR}/.exercism-config exercism)
21 |
22 | # Open instructions in VS Code
23 | code INSTRUCTIONS.md
24 |
25 | # Leave a friendly message about the terminal
26 | echo "Here's a terminal for using the excerism CLI tool 💪"
27 |
28 | github:
29 | prebuilds:
30 | main: true
31 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2021 Peter Strömberg
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Run the Exercism Clojure track with Full Interactive Programming in the browser
2 |
3 | This is a [Clojure](https://clojure.org/) template configured for running the [Exercism Clojure Track](https://exercism.org/tracks/clojure) in a zero-install fashion in your browser, leveraging [Calva](https://calva.io) and [Gitpod](https://www.gitpod.io/).
4 |
5 | 
6 |
7 | ## Rationale
8 |
9 | Why would you want to use another web browser editor than the Exercism built in one? Because this one supports Interactive Programming (aka REPL Driven Development). It is one of Clojure's main super powers and if you are going to spend time learning Clojure, you probably also should learn the habits and the workflow that makes Clojure programmers so happy and effective.
10 |
11 | ## How to use
12 |
13 | 1. Copy this project by click the ”Use this Template” button.
14 | * Reading this from your newly created copy? Awesome.
15 | 1. Open this link: https://gitpod.io/from-referrer/
16 | * This will open the repository in a Gitpod workspace in the browser.
17 | * _NB: If you don't have a Gitpod account, use the option to **Sign-up with GitHub**._
18 |
19 | Using Safari?
20 |
21 | Then the link probably won't work. Instead prepend the repository URL with `https://gitpod.io/#` and load that page.
22 |
23 |
24 |
25 | It might take a little while, but it is well worth the wait, because in your browser you'll then have:
26 |
27 | * A Linux virtual machine with full root access and these things installed:
28 | * Java
29 | * The Clojure tools
30 | * VS Code (or Gitpod Code, actually)
31 | * With [Calva](https://calva.io) (a Clojure extension)
32 | * The `exercism` command line tool
33 | * A workspace
34 | * Prepared for hosting your Exercism exercises
35 | * Gitpod Code started and a file `INSTRUCTIONS.md` opened, which will guide you in how to download and submit [Exercism](https://exercism.orh) exercises.
36 |
37 | ## See also
38 |
39 | * [Get Started With Clojure](https://calva.io/get-started-with-clojure/) - An introduction to Clojure and to Calva.
40 | * [Rich 4Clojure](https://github.com/PEZ/rich4clojure) - Another exercise/problem based way of learning Clojure. A very good complement to the Exercism Clojure track!
41 |
42 | ## Contribute
43 |
44 | Please help keeping this template useful and helpful by provding issues and pull requests.
45 |
46 | Also, please consider sponsoring my open source work: https://github.com/sponsors/PEZ ❤️
47 |
48 | ## The template
49 |
50 | Wondering where the ”Use this Template” button is? You might be reading this from a copy of the template, which is here: https://github.com/PEZ/clojure-exercism-template
51 |
52 | ## Licence
53 |
54 | MIT
55 |
56 | Free to use, modify and redistribute as you wish. 🍻🗽
--------------------------------------------------------------------------------
/INSTRUCTIONS.md:
--------------------------------------------------------------------------------
1 | # How to use this project
2 |
3 | Prerequistes: You should have followed the instructions in the [README](README.md) file. And be reading this in **Gitpod Code** in your browser.
4 |
5 | This repository, when opened with Gitpod, gives you:
6 |
7 | 1. A Linux virtual machine with full root access and these things installed:
8 | * Java
9 | * The Clojure tools
10 | * VS Code (or Gitpod Code, actually)
11 | * The `exercism` command line tool
12 | 1. A workspace
13 | * With this file
14 | * Prepared for hosting your Exercism exercises
15 | * Gitpod Code started and this file opened
16 |
17 | You will interact with the workspace from the VS Code integrated terminal and by editing exercise code files.
18 |
19 | New to Clojure or Calva?
20 |
21 | If you are new to Clojure or Calva (the VS Code extension used in this project) then I strongly suggest you start with checking out [Get Started With Clojure](https://calva.io/get-started-with-clojure/). It is also using [Gitpod](https://gitpod.io) to give you a zero-install introduction to using the Clojure REPL in the editor. (Plus it has a basic Clojure guide that can come in handy when working through the exercises here.)
22 |
23 |
24 |
25 | ## Setup
26 |
27 | First you need to configure the `exercism` CLI tool with your Exercism API token, and make it use this workspace for the exercises.
28 |
29 | You find your token here: https://exercism.org/settings/api_cli
30 |
31 | Then issue this command in the integrated terminal:
32 |
33 | ```sh
34 | exercism configure -w . -t
35 | ```
36 |
37 | ## Workflow
38 |
39 | To work with the exercise you will for each one repeat these steps (step details below):
40 |
41 | 1. Download the exercise
42 | 1. Open the test file
43 | 1. Start the Project's Clojure REPL (Jack-in)
44 | 1. Load the test file in the REPL
45 | 1. Load the implementation file the REPL
46 | 1. Implement the solution
47 | 1. Edit code, evaluate, edit code, evaluate, edit code, evaluate, and so on and so forth
48 | 1. Run tests
49 | 1. Until tests pass and you are fine with submitting the solution
50 | 1. Submit the solution
51 | 1. Check for feedback at Exercism.org
52 | 1. If it is a mentored exercise, you will probably get enough feedback to want to repeat from *Implement the solution*
53 | 1. Celebrate! 🎊
54 |
55 | ### Download the excercise
56 |
57 | You'll use the `exercism` CLI tool for this and for when submitting solutions.
58 |
59 | The command structure for downloading an exercise looks like so:
60 |
61 | ```shell
62 | exercism download --exercise= --track=clojure
63 | ```
64 |
65 | You can copy the CLI command from the Exercism page, e.g. https://exercism.org/tracks/clojure/exercises/hello-world. This will copy this command:
66 |
67 | ```sh
68 | exercism download --exercise=hello-world --track=clojure
69 | ```
70 |
71 | Executing that will create the directory `clojure/hello-world` which contains:
72 |
73 | 1. The Clojure project file
74 | 1. A `src` directory, with the _implementation_ file `hello_world.clj` (note that the dashes in the slug are replaced with underscore when naming Clojure sourrce files)
75 | 1. A `test` directory with the _test_ file `hello_world_test.clj`
76 | 1. Some Markdown files you can examine to get to know more about the exericise.
77 |
78 | ### Open the test file
79 |
80 | Open `clojure/hello-world/test/hello_world_test.clj`
81 |
82 | ### Start the project REPL for the exercise (Jack-in)
83 |
84 | With the test file open, issue the command **Start a Project REPL and Connect (aka Jack-in)**. It's avaialble from the VS Code Command Palette (`Ctrl+ALt+C Ctrl+ALt+J`) as well as via the REPL button in the statusbar.
85 |
86 | 
87 |
88 | (If you are looking for the REPL button before having opened the test file, you might not find it. Calva activates when a Clojure file is opened.)
89 |
90 | In the Project type menu select `deps.edn`.
91 |
92 | 
93 |
94 | You don't see a deps.edn option?
95 |
96 | If you don't see a `deps.edn` option, it is probably because you submitted a solution to the `clojure/hello-world` exercise back when it only had a Leiningen configuration. Don't worry. just select the **Leiningen** project type instead.
97 |
98 |
99 |
100 | Next Calva will ask you to select an alias to start with. This is because the `deps.edn` file defines a `test` alias. Whatever you do, _don't select it!_ 😊. Just press `Enter` or click **OK**.
101 |
102 | 
103 |
104 | (Calva will actually pop up a warning about selecting the `test` alias.)
105 |
106 | The Calva **Output/REPL Window** will open and report progress on the starting of the REPL. It is a file named `output.calva-repl`. It will later show the results of the test runs when you check if you have gotten your solution to pass its tests.
107 |
108 | A note abut the Output REPL Window
109 |
110 | This window/file is also a REPL prompt where you can evaluate Clojure code. I suggest you don't use it much for this, because all Clojure files you work with support evaluating Clojure code with the REPL.
111 |
112 |
113 |
114 | ### Load the test file in the REPL
115 |
116 | Once the REPL is started, it is connected to your editor and ready to evaluate code for you. 🎉
117 |
118 | However, _it won't evaluate any code unless you ask it to_. To make the REPL aware of the exerice's test you need to **load** the test file. You do this by having the file active and issue the command:
119 |
120 | **Calva: Load Current File and Dependencies**, keyboard shortcut: `Ctrl+Alt+C Enter`.
121 |
122 | ### Load the implementation file
123 |
124 | Open `clojure/hello-world/src/hello_world.clj` (create it if it isn't there) and load it, `Ctrl+Alt+C Enter`.
125 |
126 | ### Implement the solution
127 |
128 | This is where the fun begins! Your task is to write a solution that will make the tests of the exercise pass. Here is where you should take full advantage of Clojure Interactive Programming. Write small pieces of code and evaluate them. Rinse and repeat. Rinse and repeat again, and so on. (Maybe for `hello-world` you won't need to rinse and repeat so often, but anyway.)
129 |
130 | Now and then you'll want to run the tests. There's a command for that:
131 |
132 | **Calva: Run Tests for Current Namespace**, `Ctrl+Alt+C T`
133 |
134 | Rinse and repeat!
135 |
136 | ### Submitting a solution
137 |
138 | Once you are good with your solution you'll want to submit it. The command for this looks like so:
139 |
140 | ```sh
141 | exercism submit
142 | ```
143 |
144 | Tips for getting the file path
145 |
146 | A convenient way to get the file path is to use the VS Code command **Copy Relative Path** when the file is active. Or right-click the file's tab or the filename in the Explorer pane and select **Copy Relative Path** from the pop-up menu. If you are submitting several files, use the Explorer pane to get the relative path of the `src` directory containig the solutions. Then append `/*.clj` after pasting.
147 |
148 |
149 |
150 | From there it will be up to you and your mentor how many times you'll be submitting new iterations.
151 |
152 | ### Celebrate 🎉 🎊
153 |
154 | Learning Clojure this way is very rewarding. I hope you celebrate the steps you take and that you spend some time reflecting and reviwing your mentors. They deserve feedback and appreciation for all the work they are contributing to help the rest of us improve.
155 |
156 | ### Next exercise!
157 |
158 | When you are ready for the next exercise, consider closing the Calva Output/REPL window for this exercise first. It might get confusing when a second window opens.
159 |
160 | ## See also
161 |
162 | * [Get Started With Clojure](https://calva.io/get-started-with-clojure/) - An introduction to Clojure and to Calva (the VS Code Clojure extension this project uses).
163 | * [Rich 4Clojure](https://github.com/PEZ/rich4clojure) - Another exercise/problem based way of learning Clojure. A very good complement to the Exercism Clojure track!
164 |
165 | ## Support my open source work ❤️
166 |
167 | I spend a lot of time trying to make it easier to get started with, and enjoy, Clojure. The fact that I have sponsors encouraging this makes my family much more ready to accept the trade-offs I make. Please consider: https://github.com/sponsors/PEZ
168 |
--------------------------------------------------------------------------------