This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-10-19
Channels
- # beginners (37)
- # boot (96)
- # cider (23)
- # clara (2)
- # cljs-dev (40)
- # clojars (1)
- # clojure (149)
- # clojure-conj (1)
- # clojure-dev (2)
- # clojure-dusseldorf (5)
- # clojure-france (82)
- # clojure-italy (1)
- # clojure-nlp (1)
- # clojure-russia (13)
- # clojure-spec (24)
- # clojure-uk (62)
- # clojurescript (131)
- # core-async (13)
- # core-logic (7)
- # data-science (1)
- # datomic (10)
- # defnpodcast (3)
- # docker (4)
- # emacs (3)
- # events (4)
- # hoplon (68)
- # klipse (4)
- # leiningen (1)
- # off-topic (5)
- # om (140)
- # onyx (16)
- # pedestal (24)
- # planck (10)
- # proton (2)
- # re-frame (9)
- # reagent (4)
- # remote-jobs (1)
- # ring-swagger (16)
- # untangled (5)
- # vim (8)
- # yada (30)
would appreciate some pointers on achieving this (simplified) transformation.. from data
to transformed
:
(let [data {:parent {:childn {:unknown-nested-data {}},
:childn+1 {}}
:known-child {:unknown-nested-data {}}},
data-expected {:childn {:unknown-nested-data {}},
:childn+1 {},
:known-child {:unknown-nested-data {}}}
transformed (-> (assoc {} :known-child (:known-child data))
(assoc,, (keys (:parent data)) {}))]
(println (= data-expected transformed))
transformed)
- number of children under :parent unknown (represented here as :childn, :childn+1)
- :known-child is known key namethat seems like a pretty big let statement. you might want to factor out the transformation into its own function for readability.
@shooodooken can you give an example of an input data
and the desired output?
(defn web-credentials [{:keys [email password]}]
(microsoft.exchange.webservices.data.credential.ExchangeCredentials. email password ""))
& the class I'm trying to instantiate: https://github.com/OfficeDev/ews-java-api/blob/7f8793a3faef91a7eb22dae0d9cff8118a66cd24/src/main/java/microsoft/exchange/webservices/data/credential/ExchangeCredentials.java
I'm getting "no matching constructor found", so I think I'm just not reading the java right
Hi! I'd like to use case
with type
, however this doesn't seem to work:
Any tricks I forgot? Do I have to use condp
? match
?
This works, but doesn't seem ideal:
case cases have to be compile-time literals and classes are not compile-time literals
if you’re going this route though, I’d suggest using .getName rather than str
note that class names are not unique in a jvm though - every classloader is independent and can load the same class
if you’re conditionally doing something based on type, the fastest way to do that in Clojure is with a protocol
Thank you for the explanation @alexmiller ! Now using (condp contains? (type ch) ..
after @jr tip in #clojure
Cool (but be aware that matching on classes like that may not work 100% of the time due to the classloader caveat above)
I've got a problem that I know how to do with a C style for
loop, but I can't figure out a nice way to do it functionally.
I want to iterate over a vector, and if an item matches a specified value, I want to output the same vector with the item before the matching value removed.
So if my original value was [1 2 a b c 3 4]
and my function was matching on the value 3
, the output should be [1 2 a b 3 4]
Any ideas?
@jawart: When I run it, I don't know the value of c - example is pretty contrived :)
@shaun-mahood here is one thing you could do