This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-03-02
Channels
- # aws-lambda (1)
- # beginners (28)
- # boot (54)
- # cider (11)
- # clara (28)
- # cljs-dev (74)
- # cljsrn (13)
- # clojure (342)
- # clojure-austin (3)
- # clojure-dusseldorf (4)
- # clojure-france (2)
- # clojure-greece (11)
- # clojure-italy (42)
- # clojure-poland (7)
- # clojure-russia (11)
- # clojure-spec (44)
- # clojure-uk (156)
- # clojure-ukraine (4)
- # clojurescript (102)
- # cursive (17)
- # datascript (19)
- # datomic (17)
- # dirac (39)
- # emacs (22)
- # funcool (56)
- # hoplon (25)
- # jobs (3)
- # jobs-discuss (31)
- # leiningen (2)
- # luminus (4)
- # lumo (3)
- # off-topic (47)
- # om (51)
- # onyx (57)
- # re-frame (13)
- # reagent (57)
- # remote-jobs (15)
- # ring (9)
- # ring-swagger (7)
- # robots (2)
- # rum (6)
- # specter (16)
- # sql (7)
- # test-check (37)
- # untangled (7)
- # yada (5)
I am trying to remove white spaces including new lines from the string, which is the best way to achieve it? should I write a function or use some function which is already available
clojure.string
has some fns you probably could use. trim
, trim-newlines
, or replace
might be good ones to look at.
Connecting to the port from the command line the connection is accepted but then immediately closed again.
My guess is that by calling accept
on server-sock
again the client sock
is automatically closed. If so there must be a known way to deal with that, but how? (I'm not fluent in Java).
Or is it the with-open
macro?
vinai yup, this should be of interest 🙂 https://stuartsierra.com/2013/03/29/perils-of-dynamic-scope
anyone know if there is an easier way to do this:
given:
[:a :b :c 1 2 3] => [:a 1 :b :2 :c 3]
currently I'm thinking the easiest way is:
(interleave (take 3 [:a :b :c 1 2 3] ) (drop 3 [:a :b :c 1 2 3]))
shan
user=> (apply zipmap (split-at 3 ["a" "b" "c" "1" "2" "3"]))
{"a" "1", "b" "2", "c" “3”}
this is what I got in the end
(defn vec->map [v]
(let [num-pairs (/ (count v) 2)
ks (take num-pairs v)
vs (drop num-pairs v)]
(clojure.walk/keywordize-keys (apply hash-map (interleave ks vs)))))
@schmee your version is nicer
(defn vec->map-2 [v]
(let [num-pairs (/ (count v) 2)]
(clojure.walk/keywordize-keys (apply zipmap (split-at num-pairs v)))))
@shan When you have one sequence of keys and another of values I think zipmap is the right tool for the job. If you know how many items there should be in the resulting map, you can use partition to get the keys and values sequences: (apply zipmap (partition 3 ["a" "b" "c" "1" "2" "3"]))
.
@joshkh keep me posted, I think I'll have to write code like yours soon and I'd be curious to know if it works 🙂
what are the recommended libs for doing relational operations on data, eg JOIN, SELECT, or stuff like you'd find in SQL? iirc, specter isn't for this kind of thing, or is it?
clojure.set has ops for that
they don’t go real deep, but depending what you need, it might be sufficient
i'll check em out thanks