Fork me on GitHub
Drew Verlee02:04:16

@agile_geek @yonatanel I’m having to much fun with this. here is my post on The Bridge Pattern!


I want to find something that would get me some real experience working in Clojure. Sadly I'm not creative when it comes to side projects. I'm thinking helping to do some open source work, but not sure where to start when looking for a project.


@drewverlee nice use of Klipse! I haven't written a blog on Clojure for about a year but next chance I have I'm going to try and use it.


@drewverlee I'm getting Cannot load script: Error: in all the klipse boxes.


@yonatanel does that url work for you? (if you click it)


Ok, now the blog post looks fine


Hi all, I'm trying to pull data from Oracle using and then output it to csv.


Using for that purpose.


I have the following code...


currently I'm using string? as the predicate function, which results in each column being quoted in the csv


As I'm only looking at the vals from the returned maps, is there a way to specify columns I want quoted, for instance by index, or by doing things differently and using the map keys?


(doto (java.util.Stack.)
  (.push "Latest episode of Game of Thrones, ho!")
  (.push "Whoops, I meant 'Land, ho!'"))
can anyone tell me how I can use a final class like this? I need to call functions on it like this:
Azure azure = Azure.configure()        


that would likely be

(-> (Azure/configure)
   (.withLogicLevel LogicLevel$BASIC)
   (.autheticate credFile)
not 100% certain on LogicLevel$BASIC though


did work except the LogLevel$BASIC thing


LogLevel/BASIC worked


Having clojure.spec troubles. Methinks I am missing something... Why do the offical guide's sampling generator examples barf with classpath errors? Found online suggestions to require clojure.spec.test, but to no avail. Is there a fix so I can play with spec's generators? Here is an example to show what fails. Modify project.clj to the latest org.clojure/clojure:

$ lein new app test
$ cd test
$ sed -i -e 's/1.8.0/1.9.0-alpha15/' project.clj
$ lein repl


=> (require '[clojure.spec :as s] '[clojure.spec.gen :as gen] '[clojure.spec.test :as st])
=> (gen/generate (s/gen int?))  ;;; from 

FileNotFoundException Could not locate clojure/test/check/generators__init.class or clojure/test/check/generators.clj on classpath.  clojure.lang.RT.load (

Alex Miller (Clojure team)18:04:15

Need to include test.check in your deps

Alex Miller (Clojure team)18:04:36

This is mentioned in the guide


So took out test.check but the FNFE still throws...

=> (require '[clojure.spec :as s] '[clojure.spec.gen :as gen])
=> (gen/generate (s/gen int?))  ;;; from 

FileNotFoundException Could not locate clojure/test/check/generators__init.class or clojure/test/check/generators.clj on classpath.  clojure.lang.RT.load (


oh, duh. My bad.... Thanks @alexmiller.


Fixed with

:dependencies [[org.clojure/clojure "1.9.0-alpha15"]
                 [org.clojure/test.check "0.9.0"]]

Drew Verlee20:04:45

When Destructuring, can i have the :as result contain the default values set in the :or specification?


@drewverlee No, the :as part is “as passed in”, without defaults applied.

Drew Verlee20:04:41

defn foo [{:keys [a b] :or {:a "a" :b "default"} :as x}] x)
(foo {:a "hi"})
// result => {:a "hi"} 
// What i want is {:a "hi" :b "default"}


That can be kinda frustrating at times.

Drew Verlee20:04:48

i suppose i just combine the two to get what i want then


What I tend to do in such situations is

(defn foo [x]
  (let [{:keys [a b] :as x} (merge {:a "a" :b "default"} x)] x))


i.e., make the defaults explicit and destructure after that


also, almost always if I want defaults it’s worth having a top level def for them - they can serve as documentation for someone setting their options

Drew Verlee20:04:57

so keep the defaults outside the function? ok yea, that sounds right.

Drew Verlee20:04:17

(def some-defaults {}).


(def foo-defaults {…}) (defn foo "foo on a bar, uses foo-defaults for options not specified" [opts bar] …) - that way someone browsing api docs or using clojure.repl/doc can figure things out quicker


is lazy-seq basically always used with cons to build the sequence? I kinda get lazy-seqs, but I still don't have a really strong intuitive understanding and pretty much all the examples I've seen are of the general shape:

(defn recur-func [a]
    (cons a (recur-func (f a)))))

Alex Miller (Clojure team)20:04:28

yes (or the more advanced chunked version)


I'm a little confused on swap! and assoc-in I think. My code almost works, but I can't quite figure out where I'm messing up. I've got a vector of maps, and the value of a key :tables inside that map is also a vector of maps. I've got a function that looks like (assoc-in (:tables selected-schema-map) [table-index :columns] (query-column-names-and-data-types table-name)) which gives me the proper value for my swap!. But when I pass the above as the value, let's call it new-data for simplicity in on my swap as (swap! my-atom assoc-in [schema-index :tables] new-data) the swap overwrites the :tables vector (duh) but not with what I expected.


it properly swaps in for the given index what the correct data should be, but instead of merging the previous hash-map with the new one as I would have expected, because the assoc-in function alone does, it simply keeps the last index swapped in.


I can link someone some actual code or some snippets of what the data looks like so that my question is more clear; I just don't want to litter the channel more than I already have. 😂


assoc-in on (:tables foo) doesn’t return foo


(update foo :tables assoc-in …)


or in a swap!, they stack nicely

(swap! foo update :tables assoc-in ...)


it’s almost like forth


that assoc-in produces the vector of maps that I want


so my confusion in regards to what you're saying @noisesmith is when I do (swap! db-structure assoc-in [schema-index :tables] new-data)


If my atom is [ {:table_schema "vavs", :tables [{ .... }]}] then isn't assoc-in [index :tables] targeting that inner vector?


on the swap, I mean, not the other assoc-in


I mean, I guess clearly it isn't. But that's where my confusion is.


notice you have two different lookups going on - one for getting a value from the atom (at :tables, 8th) and another for a deeper nesting (0, :columns)


I think things will make sense if you reorganize so you only do the nested lookup in one place, so that the update-in returns the whole structure you actually want updated


It took me a bit and I feel silly now, but I got it. Thanks @noisesmith .


well, that’s a sign of learning, if what used to be confusing is now clear

Drew Verlee23:04:25

@agile_geek In case your interested in the latest edition of my GOF design patterns in clojure series here is the builder pattern: 20 minutes to know what should be done, 4 hours to explain why i think thats implementation and how it relates to FP to OO. Translating these design patterns from the GOF is painful. Anyone is welcome to give feedback on these. I should make a place where people can comment.


Good day #beginners, I'm building a small database system and I'm not sure what's the idiom to structure it: I have a Serialisation, Replication, Query, State components, they're mostly protocols / records communicating through core.async channels. How should I group them into a single DB object?

Drew Verlee23:04:45

@lsenta I'm not sure I follow your meaning, but it's possible you might want to pick up, As it discussed several ways to group functions and there pros and cons