Abbreviation of constructs where you let vars and then want to create a map.
(let [a 1
b (inc a)]
{:a a
:b b}
(require '[dsann.let-map :refer [let-map])
(let-map
a 1
b (inc a)
...)
=> {:a 1 :b 2}
let-map2 should be preferred because the syntax is closer to let. It also adds additional features: namespaced keywords and value filtering (particularly nils)
(require '[dsann.let-map2 :refer [let-map])
(let-map
[a 1
b (inc a)
...])
=> {:a 1 :b 2}
refer to dsann.let-map2-test for examples
io.github.davesann/let-map {:git/tag "v9" :git/sha "d0f023e"}if you want to list all versions
git show-ref --tags --abbrev
- clj
- cljs
- bb
- Names that start _ are removed from the final map
- Useful for intermediate values
- Destructuring works
- Refer to tests for examples: let-map tests
- since v8:
- The input map type will be retained when using assoc versions
- If you want to let-map a specific map type then
(let-assoc (my-map-type) a 1 ...)
- let-assoc:
- like let-map but add to a provided map
- sym-map:
- create a map from a list of symbols. Keys will be the symbol names
- assoc-syms
- like sym-map but add to a provided map
- let-assoc:
- like let-map but add to a provided map
- sym-map:
- create a map from a list of symbols. Keys will be the symbol names
- assoc-syms
- like sym-map but add to a provided map
all variants that end in -ns create namespaced keywords
- let-map-ns
- let-assoc-ns
- sym-map-ns
- assoc-syms-ns
all variants that end in a '-' filter based on values. the default is to filter nils.
-
let-map-
-
let-assoc-
-
sym-map-
-
assoc-syms-
-
let-map-ns-
-
let-assoc-ns-
-
sym-map-ns-
-
assoc-syms-ns-
See namespaces:
if using clj-kondo and you are seeing unresolved-symbol errors
- Ensure there is a .clj-kondo directory in your project
- Then run the following command to copy configs to exclude these errors
clj-kondo --lint "$(clojure -Spath)" --copy-configs --skip-lint