This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-02-22
Channels
- # aws-lambda (2)
- # beginners (195)
- # boot (47)
- # capetown (14)
- # cljs-dev (7)
- # cljsjs (1)
- # cljsrn (1)
- # clojure (103)
- # clojure-berlin (28)
- # clojure-dev (92)
- # clojure-dusseldorf (3)
- # clojure-finland (2)
- # clojure-germany (3)
- # clojure-italy (4)
- # clojure-russia (37)
- # clojure-spec (104)
- # clojure-uk (52)
- # clojured (2)
- # clojurescript (124)
- # community-development (7)
- # core-async (6)
- # cursive (41)
- # datomic (53)
- # dirac (2)
- # emacs (16)
- # hoplon (5)
- # jobs (3)
- # juxt (12)
- # lein-figwheel (6)
- # leiningen (15)
- # luminus (3)
- # off-topic (49)
- # om (5)
- # onyx (13)
- # overtone (27)
- # re-frame (7)
- # reagent (46)
- # ring (3)
- # ring-swagger (11)
- # spacemacs (2)
- # specter (40)
- # sql (6)
- # untangled (149)
- # vim (14)
How can I merge to vectors to return a vector with each value of both vectors joined into a subvector?
["a" "b" "c"] ["1" "2" "3"] -> [["a" "1"] ["b" "2"] ["c" "3"]]
improving on mpenet’s solution to precisely match the spec: use mapv
instead
so (mapv vector ["a" "b" "c"] ["1" "2" “3”])
Thank you. So easy.
issue advertising: if you care about spec -> swagger support (among other things) you might want to vote on http://dev.clojure.org/jira/browse/CLJ-2112
I'm looking for a way to cycle paren style round, curly, square in emacs, can't see anything obvious in cljr
I have a lazy sequence of hash-maps. I want to return the best hash-map found within some time limit when reducing the sequence. Any ideas on the simplest way to do this?
precisely, technically you do this inside a (reduce ... ) too if you put the time checking into the reducer function and use something called "reduced" (which I belive short circuits the rest of the list)
@ddrbt: https://clojuredocs.org/clojure.core/reduced also causes short circuiting if you absolutely want to use 'reduce' in stead of loop/recur
Thanks. I’ll try that out. I was scratching my head thinking about atoms and channels 😬
well, above suggestion = single threaded, if you want to do a multi threaded search for opt, you proably need channels or queues
@qqq hmmm… thanks. I’ll try out the loop/recur method first and see if it’s fast enough
hey guys, my brain somehow tries to relate clojure agents to scala actors. Am I building the right mental model for it or should I just forget that similarity to not screw things up ?
Hi folks, I'd like to introduce my first Clojure library for browser automation using Webdriver API. If anybody needs to run frontend tests, feel free to use it and and share your ideas regarding to how te make it better. Thanks! https://github.com/igrishaev/etaoin
igrishaev: that looks very cool. i have not used this kind of tool. can i use it to scrape? e.g. get the list of items in a drop down, so i can select
wow that seems like a good idea @igrishaev
I assume the selenium java libs are good quality as selenium is written in java (?) - what prompted you to implement the protocol directly?
well, initially, I was wondering how does selenium work under the hood. Once I've found it's just HTTP API, I decided to implement my own version of it. I believe, pure-clojure way makes the code clearer and easier to understand.
@pesterhazy and we also had some troubles with clj-webdriver, for example I could not launch our unit tests from Emacs.
makes sense
@socksy, this may be interesting to you ^^
@igrishaev Do you have the code online?
@igrishaev Sorry, I missed that and yes, thats what I meant
David, if you don't mind my asking, what's your background? I'm just starting out with Clojure too, coming from C# / F# / Python. I may be able to recommend some books etc. One thing I still struggle with is a good IDE/Dev setup for Windows. I'm using Lighttable now, but will probably switch to Cursive soon. ps - there's a beginners channel for Clojure too.
genec: Hello! Honestly i am in the midst of a career change and don't really have much experience with programming in general, other than a bit of python to understand the basics. I will gladly accept recommendations for beginners books in Clojure and even books on functional programming in general. Im basically starting from scratch.
I have IntelliJ and Cursive installed (the latter is free for personal use, to my understanding), but I've been using Atom recently.
@U46LM0HR6 are you using Atom on Windows?
@davidtpriest http://www.braveclojure.com/ and Living Clojure are both very good. Also, Clojure West is coming up next month in Portland and there's a 2 day intro class prior to the conference.
@U46LM0HR6 Thanks, and you don't have any issues? When I use proto-repl/Atom repl tends to get stuck. Are you on Win 10?
@U342BD0RG Thanks. Multiple sources have recommended brave clojure as well as living clojure. Will look into them. Unfortunately i live in VA but would totally go if it were in my neck of the woods. 😃
Oh. I have the proto-repl plugin installed, but I haven't actually used it yet. I am on Windows 10, so I'll let you know, when I use it.
@davidtpriest I came to Clojure from a non-programming background too, and found Nightcode was a good IDE to start off with. If you haven't already been there, also check out http://www.braveclojure.com.
@nico welcome and good luck on your path. We have the #beginners channel here and also a dedicated #code-reviews channel. I think both are appropriate for your question 🙂
@igrishaev - Thanks! I followed the readme example, and it worked like a charm! Brilliant stuff!
out of curiosity: why does distinct
uses a Clojure's immutable hash set? would it be faster to use java's mutable hashset since no side effects would take place outside of this function?
https://github.com/clojure/clojure/blob/clojure-1.9.0-alpha14/src/clj/clojure/core.clj#L4933
looking at the code for distinct
just now, I noticed recur
being used in the "then" portion of an if
block, and sure enough, when I try to compile this:
(defn distinct'
[coll]
(let [step (fn step [xs seen]
(lazy-seq
((fn [[f :as xs] seen]
(when-let [s (seq xs)]
(if (contains? seen f)
(recur (rest s) seen)
(cons f (step (rest s) (conj seen f)))))
xs seen))))]
(step coll #{})))
I get CompilerException java.lang.UnsupportedOperationException: Can only recur from tail position
... so, how is this compiling in clojure.core?@joshjones the (fn [[f :as...
contains xs
and seen
, you just slurped in the arguments
@timrichardt what does that have to do with recur
?
that makes xs and seen the tail position
only seen
, to be exact
i see now why the recur is in a tail position, because if
is in the tail position of the function -- but why won't it compile in a repl?
it does 🙂
a.h> (defn distinct'
[coll]
(let [step (fn step [xs seen]
(lazy-seq
((fn [[f :as xs] seen]
(when-let [s (seq xs)]
(if (contains? seen f)
(recur (rest s) seen)
(cons f (step (rest s) (conj seen f))))))
xs seen)))]
(step coll #{})))
#'agp.handler/distinct'
a.h> (distinct' [1 2 2 3])
(1 2 3)
you just messed up the parenthesis
in your example the if
is not in the tail position
@rauh so a hashset version that uses equiv in a mutable way would basically be (transient! #{})
right?
@nottmey you can also just depend on [org.clojure/algo.generic "0.1.2"]
, require [clojure.algo.generic.functor :as f :only [fmap]]
, and call fmap
directly -- (fmap func your-map)
@clojurebot ewww … was (reduce-kv #(assoc %1 (name %2) %3) {} {:a 1 :b 2 :c 3})
looks alright, ty both
@joshjones fmap
seems to apply to the value though https://github.com/clojure/algo.generic/blob/master/src/main/clojure/clojure/algo/generic/functor.clj#L35
@plins plumbing.core
has fn->
:
((p/fn-> name symbol) :kwd)
kwd
https://github.com/plumatic/plumbing/blob/318af7798bb701607aaae8639d12829014941184/src/plumbing/core.cljx#L315What's the right way to get a date from clj-time to work with nippy? I can manually cast back and forth, but it seems like the kind of thing I should be able to do by extending the serializer
all I need to do is use the clj-time.coerce/to-date and from-date functions, since nippy already serializes java.util.Date objects...
while I'm asking about this, are there any reasons not to do that particular coercion? Loss of information etc.?
@shader If you’re talking about extending the protocol, then be aware that it would apply for all code in your app, not just the pieces you’re thinking about.
@shader one of the main reasons I favor Transit over other marshalers, it's context dependent. i.e. you can override stuff for a single writer.