Fork me on GitHub
#clojure
<
2017-01-22
>
schmee00:01:39

tbaldridge do you have any personal recommendations when it comes to rules systems and logic engines in clojure?

mac00:01:21

@schmee For a rules engine I would look at Clara http://www.clara-rules.org/

schmee00:01:58

mac what’s been your experience using it?

schmee00:01:42

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

mac00:01:44

@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.

mac00:01:11

@schmee Which kind of project are you considering using it for?

seancorfield00:01:37

@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.

seancorfield00:01:17

(sorry for the slow response, I was at the Women's March in Oakland, CA most of the day)

sova-soars-the-sora01:01:58

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?

arewaolakunle03:01:42

I'm new here and specifically looking for ring-swagger.... Can't find it

bcbradley03:01:39

is it possible for a go-loop that constantly derefs an atom to block another go-loop from swap! on that atom?

devn04:01:54

@bcbradley: what are you trying to accomplish?

tbaldridge04:01:09

@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)

sova-soars-the-sora04:01:24

@bcbradley i think a swap is guaranteed to take place eventually. if i understand your question.

bcbradley04:01:28

I'm trying to implement a cache

bcbradley04:01:36

nvm i isolated my problem

seylerius05:01:26

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])

seylerius05:01:03

Oh, I just realized it.

seylerius05:01:46

No, that should work.

seylerius05:01:37

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)))

seylerius05:01:51

Attempting to compare nil and a number with max fails.

seylerius05:01:35

And yet that doesn't fix it.

seylerius05:01:41

Ah, there we go.

dpsutton06:01:25

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

devn06:01:50

@dpsutton: huh, I don't recall seeing anything about a max retry on the spin loop, but perhaps I've missed something

kenrestivo06:01:37

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

devn06:01:41

I guess I just assumed contention was something you'd eventually be forced to deal with

kenrestivo06:01:53

ended up with `(let [[[ff sf] [fs ss] [ft st]] day-shifts]

kenrestivo06:01:53

(assoc-in ff sf)

kenrestivo06:01:53

(assoc-in fs ss)

kenrestivo06:01:56

(assoc-in ft st)))```

devn06:01:15

Probably not the most readable thing I've seen but hey, it works

kenrestivo06:01:52

ok, how about `(reduce-kv (fn [acc k v]

kenrestivo06:01:52

(assoc-in acc k v))

kenrestivo06:01:54

day-shifts)```

kenrestivo06:01:50

anyway, at least now i understand what seylerius was trying to do

kenrestivo06:01:30

golfiest i can come up with that seems to work would be

(reduce (fn [acc [k v]] (assoc-in acc k v)) {} day-shifts)

seylerius09:01:27

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 "*)*"))

seylerius09:01:55

Rule is a seq of numbers.

schmee09:01:25

what is other?

schmee09:01:31

seylerius you need to wrap the anonymous function in parens

schmee09:01:56

(#(str "(" other "*" % other “*)*”))

themirrortruth11:01:42

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

themirrortruth11:01:25

I tried to add meta info about type (Paths/get ^String "filename.txt") but this is not allowed

nooga12:01:51

@themirrortruth what are the expected arguments of Paths/get ?

nooga12:01:01

and what is Paths ?

juhoteperi13:01:04

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 []))

qqq16:01:01

anyone here using org mode + clojure? where you write clojure code in a *.org file, then tangle it to get the clj files ?

dominicm16:01:39

@qqq https://github.com/thi-ng/geom is written nearly entirely in it

qqq16:01:58

@dominicm: this is fasicnating

devn18:01:39

@dominicm: awesome projects from that user!

devn19:01:32

How did I ever miss all of this stuff? http://thi.ng

grav21:01:14

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?

gfredericks21:01:25

by "graph" do you mean "tree"?

gfredericks21:01:37

or some description of a proper graph with cycles and such

grav21:01:45

well, I guess so - it’s probably a DAC.

grav21:01:15

It is in my case at least. It’s for generating Pure Data (audio signal graph) patches

gfredericks21:01:31

probably an example would be clearer

grav21:01:22

@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

grav21:01:07

So the root object (`+`) in the edn just specifies, what its inputs are, and I need to generate the statements describing nodes and edges.

sherbondy21:01:59

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!

mrg23:01:25

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

seancorfield23:01:45

@mrg s/conformer just takes a function and applies it to the data.

seancorfield23:01:45

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

seancorfield23:01:41

Other than returning :clojure.spec/invalid, the argument to s/conformer is just applied as a data transformer.