Fork me on GitHub
#beginners
<
2015-11-26
>
lucien.knechtli03:11:57

Hi guys, I'm trying to get a duct app with postgres to connect to postgres in another container, but I can't for the life of me figure out it out. I can connect to it in the repl using the straight jdbc driver like (sql/query "" ["select 1"]) but I can't figure out how to configure the hikaricp component in the same way. I just get a ConnectException every time

lucien.knechtli03:11:11

nvm.. my container wasn't picking up changes I was making

roelof07:11:03

What do I have to change so this code https://www.refheap.com/112089 is outputtting [ 1 1 2 2 ] instead of [ ( 1 1 ) ( 2 2 )]

seancorfield07:11:45

Use mapcat instead of reduce? simple_smile

roelof07:11:57

@seancorfield: could be a solution but I think this could be done with reduce only

roelof07:11:15

the exercise yesterday could also be done without mapcat

roelof07:11:17

(mapcat #(conj %1 (repeat amount %2)) list) gives this error : clojure.lang.ArityException: Wrong number of args (1) passed to: core/duplicate/fn--6055

roelof08:11:56

found the problem. I have only 1 argument list.

roelof08:11:11

Anyone who can help me with my orginal problem

jethroksy11:11:40

Has anyone taken a look at TJOC's lazy quicksort algorithm:

(defn sort-parts "Lazy, tail-recursive, incremental quicksort. Works against and creates partitions based on the pivot, defined as 'work'." [work] (lazy-seq (loop [[part & parts] work] (if-let [[pivot & xs] (seq part)] (let [smaller? #(< % pivot)] (recur (list* (filter smaller? xs) pivot (remove smaller? xs) parts))) (when-let [[x & parts] parts] (cons x (sort-parts parts))))))) (defn qsort [xs] (sort-parts (list xs))) 

jethroksy11:11:53

OK I should put this in a gist instead

jethroksy11:11:10

The way it works seems to leave much room for improvement

jethroksy11:11:34

When working on single element lists it continues to separate it as such: '(1) -> '() 1 '()

jethroksy11:11:02

It then fails the if-let condition and cons 1..

jethroksy11:11:15

Is this really how it works, or has anyone come up with a more efficient version?

roelof18:11:08

problem solved with the help of the clojure channel. I have used the wrong function