Fork me on GitHub
#beginners
<
2017-08-14
>
seancorfield02:08:34

@adambard No, a string will work just fine. The docs recommend using a hash map with :dbtype instead, but they're all equivalent.

seancorfield02:08:17

{:dbtype "postgres" :dbname "webdev" :user "postgres" :password "mypassword"} would be the recommended connection spec @integralexplorer

seancorfield02:08:02

(but I doubt that's your issue here)

seancorfield02:08:08

If you're executing DDL (`CREATE`) you should use db-do-commands, not execute! -- the latter is for SQL, not DDL.

seancorfield02:08:41

(the recommended docs for clojure.java.jdbc are here, BTW, http://clojure-doc.org/articles/ecosystem/java_jdbc/home.html -- and I'm the maintainer of the library so I can probably help you with most stuff... although I don't use Postgres)

adambard02:08:34

Good to know, thanks!

integralexplorer04:08:54

Thanks, I have been looking at the documentation and am still trying to understand all the moving parts. I will work on it a bit more tomorrow and see if I can figure it out and if not, will ask some more questions.

seancorfield05:08:14

There's a #sql channel that's a good place to ask about JDBC stuff btw @integralexplorer /cc @adambard

sb16:08:21

could you help me what is the problem with that?

graph/ vector > ({1 [2 5]} {2 [3 4]} {5 [6 7]} {8 [9 12]} {9 [10 11]} {12 [13 14]} {15 [16 19]} {16 [17 18]} {19 [20 21]})  (map #(conj (apply second ((vec graph) (position %)) )) [2 5]) 
- that is works fully in repl but in codeingame.. not (something conj parameter problem)

drowsy16:08:41

@sb you are using the transducer arity of conj but codingame only runs clojure 1.6.0 which does not have transducers.

sb16:08:47

ok, thanks!

sb16:08:58

In this case I need to use something different.

drowsy16:08:27

and maybe complain about their outdated clojure version 🙂

noisesmith16:08:49

I don’t understand how that () without quoting isn’t throwing a big error

sb16:08:11

@drowsy where can I check the what worked in Clojure 1.6?

noisesmith16:08:15

in fact, I don’t understand what that code really does because as pasted it’s totally invalid from the start

sb16:08:38

@noisesmith One moment I show you

noisesmith16:08:42

@sb was that a ->> call that got pasted wrong? because that would work and wouldn’t use a transducer (except for the () unquoted)

sb16:08:38

(defn childrens [vct]   
 "Give back the children elements. Test with [2 5 91]"     
 (distinct 
  (flatten  
   (map #(conj (apply second ((vec graph) (position %))))   
    (keep #(if (contains? (apply hash-set nodes) %) (conj %)) vct)))))

sb16:08:47

full call was this

sb16:08:59

I know .. not so nice… etc

sb16:08:39

graph element: {1 [2 5]} {2 [3 4]} {5 [6 7]} {8 [9 12]} {9 [10 11]} {12 [13 14]} {15 [16 19]} {16 [17 18]} {19 [20 21]} vct [2 5]

sb16:08:20

I would like to get the childs of vectors. Shortest path.

noisesmith16:08:05

you are calling conj with one arg, which is weird

noisesmith16:08:26

or are you, I could be reading it wrong

sb16:08:42

i use in this way in maps .. that isn’t ok?

noisesmith16:08:56

it’s just indented wrong

noisesmith17:08:04

so the keep generates the second arg to map

sb17:08:42

(map #(conj %) [2 3])

noisesmith17:08:44

no - the conj has only one arg

sb17:08:48

in this case what is the second arg?

noisesmith17:08:50

there is no % arg to conj

noisesmith17:08:08

conj with one arg is weird - why are you doing that?

sb17:08:34

I don’t know.. i learn alone the clojure..

noisesmith17:08:34

peregrine.circle=> (conj {:a 0})
{:a 0}

noisesmith17:08:48

conj doesn’t do anything without at least a second arg

noisesmith17:08:16

iirc in older versions of clojure that would be an error, in newer versions it is allowed in case you were using apply

sb17:08:17

in this case the second arg coming from prev loop

noisesmith17:08:32

no, there is no second arg to conj in your code, and no loop

noisesmith17:08:40

perhaps you want reduce and not map?

sb17:08:16

maybe that is the solution in this case

noisesmith17:08:34

you can just not use conj, and both versions of clojure will return the same thing

noisesmith17:08:41

since that call to conj doesn’t actually do anything

noisesmith17:08:46

and older clojure doesn’t like it

sb17:08:25

Yes, I see. That is work on my desktop computer and not in codeingame.

sb17:08:02

Ok, I check with reduce. Thanks for the help!

sb17:08:22

Strange for me, because every time I used in this way.

noisesmith17:08:43

@sb your code will work if you change (conj (apply ….)) to (apply …)

noisesmith17:08:55

the conj only works in newer clojure versions, and isn’t doing anything

sb17:08:21

@noisesmith thanks I test it now!!

sb17:08:37

Works! thanks!

sb17:08:41

đź‘Ť