This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-06-17
Channels
- # announcements (2)
- # aws (4)
- # babashka (20)
- # beginners (256)
- # calva (15)
- # chlorine-clover (1)
- # cider (12)
- # clj-kondo (25)
- # cljsrn (16)
- # clojure (115)
- # clojure-europe (7)
- # clojure-finland (5)
- # clojure-italy (10)
- # clojure-nl (35)
- # clojure-spec (13)
- # clojure-uk (83)
- # clojurescript (42)
- # code-reviews (81)
- # conjure (8)
- # cursive (6)
- # data-science (1)
- # datomic (3)
- # duct (18)
- # emacs (2)
- # figwheel-main (40)
- # fulcro (21)
- # helix (1)
- # jackdaw (7)
- # java (2)
- # lein-figwheel (5)
- # luminus (1)
- # observability (12)
- # off-topic (32)
- # parinfer (5)
- # pedestal (19)
- # re-frame (5)
- # reagent (8)
- # reitit (17)
- # rewrite-clj (47)
- # rum (19)
- # shadow-cljs (48)
- # spacemacs (4)
- # sql (40)
- # tools-deps (22)
- # vrac (1)
- # xtdb (25)
I'm trying to use s/coll-of ... :kind map?
and s/or
(s/def ::k-str (s/tuple keyword? string?))
(s/def ::k-num (s/tuple keyword? number?))
(s/def ::kv (s/or
:k-str ::k-str
:k-num ::k-num))
(s/conform (s/coll-of ::kv :kind map?) {:a 1 :b "2"})
;; => {:a [:a 1], :b [:b "2"]}
I have no idea what the conform result should be, but this one looks not right@doglooksgood what about map-of?
sandbox=> (s/conform (s/map-of keyword? (s/or ::string string? ::number number?)) {:a 1 :b "2"})
{:a [:sandbox/number 1], :b [:sandbox/string "2"]}
@vlaaad Thanks for the advice!
But I want care about both key and value.
You remind me, since there's a map-of
, so coll-of
is only designed to work with sequences?
@doglooksgood figured it out after reading coll-of
docstring:
(s/conform (s/coll-of (s/or
:kw->num (s/tuple keyword? number?)
:kw->str (s/tuple keyword? string?))
:kind map?
:into [])
{:a 1 :b "2" :c 1})
=> [[:kw->num [:a 1]] [:kw->str [:b "2"]] [:kw->num [:c 1]]]
Re: god I hope it's not years 🙂 (https://clojurians.slack.com/archives/C1B1BB2Q3/p1591980460308000) Reminded me of: > We're hoping to have something releasable by Conj or the end of this year Source: https://youtu.be/KeZNRypKVa4?t=1201 Approaching one year away from that talk soon 😉
"soon" is still many months :)
what are the most difficult parts? design or implementation?