fix mistakes 1/x

This commit is contained in:
2026-09-14 08:53:09 -09:00
parent a9bf3c2b73
commit cafc844708
2 changed files with 71 additions and 18 deletions
+16 -5
View File
@@ -259,8 +259,7 @@ nil ; => nil (Null/Nothing)
(swap! counter inc) ; => 1
(swap! counter + 5) ; => 6
(dosync
(reset! counter 0)) ; => 0
(reset! counter 0) ; => 0
;; --- 14. Java Interop ---
@@ -317,9 +316,21 @@ nil ; => nil (Null/Nothing)
;; --- 18. Common Patterns ---
;; Compose functions
(defn make-upper [s] (str/upper-case s))
(def make-upper-lower (comp str/lower-case str/upper-case)) ; => #object[clojure.core$comp$fn ...]
;; Compose functions — comp reads right-to-left (like math)
;; Example: slugify — find word chunks, lowercase, join with dashes
(def slugify (comp #(str/join "-" %) #(mapv str/lower-case %) #(re-seq #"\S+" %)))
;; Usage
(slugify " Hello World ") ; => "hello-world"
(slugify "Foo Bar Baz") ; => "foo-bar-baz"
(slugify " Hello World ") ; => "hello-world"
;; Another: trim then uppercase
(def trim->upper (comp str/upper-case str/trim))
;; Usage
(trim->upper " hello ") ; => "HELLO"
(trim->upper " Clojure is fun ") ; => "CLOJURE IS FUN"
;; Partial application
+55 -13
View File
@@ -120,37 +120,79 @@ bb --nrepl-server --nrepl-port 9999
### Clojure (JVM-based)
```bash
clj -A:nrepl
> **Important**: The `clj` command needs a `deps.edn` with an `:nREPL` alias that includes the nREPL dependency. Without one, these commands will not work.
**Option A — Quick start (requires a `deps.edn`)**
Add this to a `deps.edn` in your project root:
```edn
{:aliases
{:nREPL
{:extra-deps
{nrepl/nrepl {:mvn/version "1.12.0"}}}}}
```
This starts a Clojure REPL with nREPL support. For a server:
Then start a headless nREPL server:
```bash
clj -M:nrepl-server
clj -M:nREPL -m nrepl.cmdline
```
**Option B — Plain Clojure REPL (no nREPL server)**
If you just want an interactive REPL for experimentation (no editor integration):
```bash
clj
```
This starts a standard Clojure REPL (REPL-y). You type code directly into the terminal. No deps.edn, no nREPL needed.
**Option C — Global alias (one-time setup)**
Add the nREPL alias to your global config `~/.clojure/deps.edn`:
```edn
{:aliases
{:nREPL
{:extra-deps
{nrepl/nrepl {:mvn/version "1.12.0"}}}}}
```
Then from any directory:
```bash
clj -M:nREPL -m nrepl.cmdline
```
### Connecting from Your Editor
#### Calva (VS Code)
1. Start an nREPL server (`bb --nrepl-server` or `clj -A:nrepl`)
1. Start an nREPL server (`bb --nrepl-server` or `clj -M:nREPL -m nrepl.cmdline`)
2. `Ctrl+Alt+C, Ctrl+Alt+P` — Calva connects automatically
#### Conjure (NeoVim)
1. Install Conjure via your plugin manager (`vim-plug`, `packer`, `lazy`, etc.)
2. Start an nREPL server (`bb --nrepl-server` or `clj -A:nrepl`)
2. Start an nREPL server (`bb --nrepl-server` or `clj -M:nREPL -m nrepl.cmdline`)
3. `:ConjureConnect localhost <port>` — connect to the REPL
4. Send code with `,e` (evaluate current line/form)
4. Send code with `<localleader>ee` (evaluate form under cursor)
5. Results appear inline below the code
6. Open the REPL buffer with `:ConjureShow`
**Key Conjure shortcuts:**
- `<localleader>ee` — evaluate form under cursor
- `<localleader>E` — evaluate current line/buffer
- `<localleader>pp` — evaluate and print (with pprint)
- `<localleader>dd` — evaluate and doc
- `<localleader>oo` — open result in browser (for HTML, URLs, etc.)
- `K` — doc word under cursor (built-in, no prefix)
- `<localleader>ef` — evaluate file
- `<localleader>eb` — evaluate buffer
- `<localleader>er` — evaluate root form
- `<localleader>ew` — evaluate word under cursor
- `<localleader>ep` — evaluate previous evaluation
- `<localleader>em` — evaluate marked form
- `<localleader>e!` — evaluate and replace form with result
- `<localleader>ece` — evaluate form and comment the result
- `<localleader>gd` — get definition under cursor
- `K` — get documentation under cursor (no prefix, built-in)
- `E` (visual mode) — evaluate visual selection
> Note: `<localleader>` defaults to `,` but is typically remapped in your config (e.g., to `\` or `Space`). Check `:map <localleader>` to see yours.
- `:ConjureConnect` — connect to an nREPL server
@@ -182,7 +224,7 @@ clj -M:nrepl-server
- REPL commands — create custom keybindings for common workflows (e.g., reload + evaluate)
#### Calva (VS Code)
1. Start an nREPL server (`bb --nrepl-server` or `clj -A:nrepl`)
1. Start an nREPL server (`bb --nrepl-server` or `clj -M:nREPL -m nrepl.cmdline`)
2. `Ctrl+Alt+C, Ctrl+Alt+P` — Calva connects automatically
### Loading Your Code