This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-06-28
Channels
- # admin-announcements (2)
- # alda (5)
- # arachne (4)
- # beginners (49)
- # boot (92)
- # capetown (3)
- # cider (9)
- # cljs-dev (6)
- # cljs-edn (1)
- # cljsjs (29)
- # cljsrn (4)
- # clojure (65)
- # clojure-android (1)
- # clojure-berlin (2)
- # clojure-chicago (2)
- # clojure-gamedev (2)
- # clojure-greece (11)
- # clojure-india (1)
- # clojure-japan (1)
- # clojure-new-zealand (2)
- # clojure-quebec (2)
- # clojure-russia (49)
- # clojure-spec (73)
- # clojure-uk (38)
- # clojurescript (118)
- # clojutre (4)
- # community-development (17)
- # cursive (3)
- # data-science (1)
- # datascript (1)
- # datomic (17)
- # emacs (6)
- # euroclojure (2)
- # events (2)
- # immutant (30)
- # keechma (11)
- # leiningen (4)
- # luminus (2)
- # off-topic (19)
- # om (14)
- # onyx (28)
- # planck (9)
- # re-frame (11)
- # reagent (35)
- # ring-swagger (4)
- # schema (4)
- # slack-help (6)
- # spacemacs (2)
- # specter (11)
- # testing (4)
- # untangled (88)
- # utah-clojurians (2)
- # vim (2)
- # yada (9)
is there a way in specter to delete nil keys from a map? {nil 1, :b 2}
-> {:b 2}
(transform ALL (fn [[k v]] (if (nil? k) nil [k v])) data)
I think. Can't check as I'm on my phone.
But why not just do (dissoc m nil)
?
Hi, I want to select from a vector using srange. It works well until the index is out of bounds. Can I somehow prevent getting an error and instead return only the elements found? Or is this bad coding practice of some reason? As an example, if I have a vector with three elements and does (srange 0 4) it will throw an error, but instead I would like to get the only three elements found.
@vikeri: you can use srange-dynamic for that
(defnavconstructor bounded-srange
[p srange-dynamic]
[s e]
(p (fn [aseq]
(if (< s 0) 0 s))
(fn [aseq]
(let [c (count aseq)]
(if (>= e c) c e)
))))
@nathanmarz: Great! Looks a little like black magic to me since I started looking at specter today. But it worked so I’m happy 🙂
Had to change it to this to fully accomodate my needs:
(defnavconstructor bounded-srange
[p srange-dynamic]
[s e]
(p (fn [aseq]
(let [c (count aseq)]
(cond
(< s 0) 0
(>= s c) c
:else s)))
(fn [aseq]
(let [c (count aseq)]
(if (>= e c) c e)
))))
@vikeri: defnavconstructor
works like a normal function but also integrates with Specter's inline caching