This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-01-22
Channels
- # beginners (10)
- # boot (134)
- # cider (29)
- # clara (2)
- # cljs-dev (10)
- # cljsjs (2)
- # cljsrn (13)
- # clojure (76)
- # clojure-india (4)
- # clojure-ireland (1)
- # clojure-russia (20)
- # clojure-spec (11)
- # clojure-uk (7)
- # clojurescript (88)
- # core-async (5)
- # core-logic (3)
- # cursive (17)
- # datascript (5)
- # datomic (123)
- # hoplon (8)
- # klipse (6)
- # lambdaisland (2)
- # leiningen (4)
- # luminus (2)
- # off-topic (23)
- # om (23)
- # om-next (1)
- # onyx (20)
- # pedestal (2)
- # perun (2)
- # re-frame (11)
- # ring-swagger (3)
- # untangled (12)
tbaldridge do you have any personal recommendations when it comes to rules systems and logic engines in clojure?
@schmee For a rules engine I would look at Clara http://www.clara-rules.org/
everytime I read about rules and logic engines, I go “ohh, that’s cool”, but I have a hard time seeing how to integrate it in my projects
@schmee I am experimenting with it at the moment. I find it quite easy to get started with. The idea of using records as facts works very well.
@tolitius I could run a script to break it down further... We have a suite of WebDriver tests built with clojure.test
, the rest are Expectations
. That includes all the end-to-end tests for our REST APIs, as well as our regular "unit" tests.
(sorry for the slow response, I was at the Women's March in Oakland, CA most of the day)
Sending an event from server>client using Sente... in my javascript developer console I end up with: Unhandled event: cljs.core.PersistentVector ... My client-side knows I'm sending a vector, which is good, but is not actually opening up the contents of the vector... thoughts?
Hi everyone
I'm new here and specifically looking for ring-swagger.... Can't find it
is it possible for a go-loop that constantly derefs an atom to block another go-loop from swap! on that atom?
@bcbradley: what are you trying to accomplish?
@bcbradley No, that's a big feature of Clojure. Dereffing an atom is "lock-less" and always "free". (quotes because there's still locks but they happen inside the CPU's circuits and you don't need to worry about that)
@bcbradley i think a swap is guaranteed to take place eventually. if i understand your question.
How very strange: This reduction is failing with a NullPointerException
, despite the operations beneath it being seemingly valid.
(defn shift-reducer
[acum [ks c]]
(assoc-in acum ks (max (get-in acum ks 0) c)))
(reduce shift-reducer {} day-shifts)
Where day-shifts
is a sequence that looks much like this:
([[#object[org.joda.time.DateTime 0x7969a3d1 "2017-02-01T00:00:00.000Z"] 1] nil]
[[#object[org.joda.time.DateTime 0x7969a3d1 "2017-02-01T00:00:00.000Z"] 2] 1]
[[#object[org.joda.time.DateTime 0x5becf840 "2017-02-02T00:00:00.000Z"] 1] nil])
Weirdly, though, this code works fine:
(assoc-in
(assoc-in
(assoc-in {} (first (first day-shifts)) (second (first day-shifts)))
(first (second day-shifts)) (second (second day-shifts)))
(first (nth day-shifts 2)) (second (nth day-shifts 2)))
I thought a swap would attempt 500 times and then fail. But I don't remember where I got that impression so I might very well be wrong
@dpsutton: huh, I don't recall seeing anything about a max retry on the spin loop, but perhaps I've missed something
heh, i've been away from lisp and using clojure so long, the first thing i want to do with taht code is turn it into destruturing and threading macro so that i can read it
ended up with `(let [[[ff sf] [fs ss] [ft st]] day-shifts]
(-> {}
(assoc-in ff sf)
(assoc-in fs ss)
(assoc-in ft st)))```
ok, how about `(reduce-kv (fn [acc k v]
(assoc-in acc k v))
day-shifts)```
anyway, at least now i understand what seylerius was trying to do
golfiest i can come up with that seems to work would be
(reduce (fn [acc [k v]] (assoc-in acc k v)) {} day-shifts)
Weird-ass bullshit. This block is returning a function, rather than a string, and I don't understand why:
(->> rule
(map #(str "<" % ">"))
(apply str)
#(str "(" other "*" % other "*)*"))
How to tell clojure compiler that I want to invoke method with String argument, not URI?
(Paths/get "filename.txt")
- this invoke the Paths/get
static method with URI argument type, not String
I tried to add meta info about type (Paths/get ^String "filename.txt")
but this is not allowed
@themirrortruth what are the expected arguments of Paths/get
?
Paths/get
string arity takes string + additional strings as varargs as parameters (https://docs.oracle.com/javase/7/docs/api/java/nio/file/Paths.html), so you'll probably need to provide varargs list: (Paths/get "filename.txt" (into-array String []))
anyone here using org mode + clojure? where you write clojure code in a *.org file, then tangle it to get the clj files ?
@qqq https://github.com/thi-ng/geom is written nearly entirely in it
How did I ever miss all of this stuff? http://thi.ng
Is there a tool library that can easily convert a nested data structure (graph) into a list of nodes and edges? Like the inverse of what graphviz does?
by "graph" do you mean "tree"?
or some description of a proper graph with cycles and such
probably an example would be clearer
@gfredericks So I have something like {:obj '+ :in [{:obj ‘num :args [5]} {:obj ‘num :args [7}]}
, and I need to generate something like
0 #obj num 5
1 #obj num 7
2 #obj +
3 #conn 0 2
4 #conn 0 1
So the root object (`+`) in the edn just specifies, what its inputs are, and I need to generate the statements describing nodes and edges.
Hey all, just wanted to bring attention to the fact that the GSOC deadline for orgs. to apply is Feb 9. Was really bummed out that Clojure/Script wasn’t accepted into the program last year, hope things work out this time!
https://opensource.googleblog.com/2017/01/now-accepting-organization-applications.html
Are there any examples on how clojure.spec/conformer works? I am trying to coerce a json map (including UUIDs and instants, and seqs of keywords) and I cannot find any good examples anywhere
@mrg s/conformer
just takes a function and applies it to the data.
Perhaps it helps to see it in the context of a regular predicate?
(defn p [_] false)
(defn c [_] (keyword "clojure.spec" "invalid"))
(s/conform p 42) ;;=> :clojure.spec/invalid -- because the predicate returns false
(s/conform (s/conformer c) 42) ;;=> :clojure.spec/invalid -- because c returns :clojure.spec/invalid
Other than returning :clojure.spec/invalid
, the argument to s/conformer
is just applied as a data transformer.