This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-06-05
Channels
- # beginners (135)
- # cider (30)
- # clara (66)
- # cljs-dev (18)
- # cljsrn (6)
- # clojure (115)
- # clojure-austin (1)
- # clojure-dev (10)
- # clojure-italy (7)
- # clojure-nl (1)
- # clojure-spec (18)
- # clojure-uk (26)
- # clojurescript (76)
- # cursive (2)
- # datomic (4)
- # devops (1)
- # emacs (19)
- # fulcro (159)
- # garden (3)
- # klipse (5)
- # leiningen (5)
- # off-topic (61)
- # om (7)
- # pedestal (6)
- # re-frame (17)
- # reagent (73)
- # ring-swagger (6)
- # rum (5)
- # shadow-cljs (60)
- # spacemacs (31)
- # specter (4)
- # vim (8)
- # yada (1)
There was a discussion in the #clojure channel about condp
and the use case for a similar construct that took a unary predicate (instead of a binary predicate and the second argument) but was otherwise identical. Is there an idiomatic way to write that without adding a condq
or condp-1
or something to core?
It's easy enough to take a copy of condp
and just tweak it to remove every reference to expr
and of course you could always do
(condp (fn [t _] (pred t)) :ignored
v1 r1
v2 :>> r2-fn)
(there are plenty of ways to work around it... but would a JIRA ticket/patch for this be considered for core?)
I assume this is kind of halfway between cond-> and condp?
It would be identical to condp
except for unary predicates (so it would have the :>>
behavior etc).
I'm not wedded to it -- just wondering if there's a sufficiently idiomatic alternative really.
Locally (at WS), we already have condp->
and condp->>
that work like cond->
and cond->>
but thread the expressions through the predicate, and I've often wanted that unary-predicate version of condp
-- but ended up reworking it to a longer-form cond
(repeating the predicate call in each test expr) or either cond->
or condp->
depending on what I need.
I think I've proposed condp->
and condp->>
before and been told "no" 🙂
I see the value and occasionally want something like this. Not sure if it’s worth adding to stdlib
Fair enough. I'll just keep it in our worldsingles.clojure.extensions
namespace then. If I see something like it come up elsewhere, I may open a ticket.