clojure

Clojure Selecting records from a table and inserting those records into another table

喜夏-厌秋 提交于 2019-12-25 16:13:28
问题 I am trying to insert data into one database from a different database. I have the select query working but I haven't been able to take the select query and insert it into a different database and or table. (jdbc/query db ["select * from employees where employee_id = 1927"] {:as-arrays? true}) Now, how do I now insert the above data into another table dynamically? 回答1: Let's say your employees table looks like this: create table employees ( employee_id integer, name text, primary key

Clojure Selecting records from a table and inserting those records into another table

落花浮王杯 提交于 2019-12-25 16:13:08
问题 I am trying to insert data into one database from a different database. I have the select query working but I haven't been able to take the select query and insert it into a different database and or table. (jdbc/query db ["select * from employees where employee_id = 1927"] {:as-arrays? true}) Now, how do I now insert the above data into another table dynamically? 回答1: Let's say your employees table looks like this: create table employees ( employee_id integer, name text, primary key

clojure - contains?, conj and recur

怎甘沉沦 提交于 2019-12-25 15:23:10
问题 I'm trying to write a function with recur that cut the sequence as soon as it encounters a repetition ( [1 2 3 1 4] should return [1 2 3] ), this is my function: (defn cut-at-repetition [a-seq] (loop[[head & tail] a-seq, coll '()] (if (empty? head) coll (if (contains? coll head) coll (recur (rest tail) (conj coll head)))))) The first problem is with the contains? that throws an exception, I tried replacing it with some but with no success. The second problem is in the recur part which will

clojure - contains?, conj and recur

烂漫一生 提交于 2019-12-25 15:21:22
问题 I'm trying to write a function with recur that cut the sequence as soon as it encounters a repetition ( [1 2 3 1 4] should return [1 2 3] ), this is my function: (defn cut-at-repetition [a-seq] (loop[[head & tail] a-seq, coll '()] (if (empty? head) coll (if (contains? coll head) coll (recur (rest tail) (conj coll head)))))) The first problem is with the contains? that throws an exception, I tried replacing it with some but with no success. The second problem is in the recur part which will

clojure - contains?, conj and recur

北慕城南 提交于 2019-12-25 15:20:02
问题 I'm trying to write a function with recur that cut the sequence as soon as it encounters a repetition ( [1 2 3 1 4] should return [1 2 3] ), this is my function: (defn cut-at-repetition [a-seq] (loop[[head & tail] a-seq, coll '()] (if (empty? head) coll (if (contains? coll head) coll (recur (rest tail) (conj coll head)))))) The first problem is with the contains? that throws an exception, I tried replacing it with some but with no success. The second problem is in the recur part which will

lein ritz setup error

廉价感情. 提交于 2019-12-25 14:30:23
问题 I am trying to setup ritz/lein/emacs etc to create a clojure dev environment. I installed lein plugin install lein-ritz "0.5.0" and added it to my project file. When trying lein ritz I get this exception: arash@azure:~/programming/onebreaker$ lein ritz Exception in thread "main" java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect

howto package my project resource-paths to use as project dependency?

不羁的心 提交于 2019-12-25 13:45:55
问题 I'm trying for a while with no success to package as jar file my resource-paths files (.dylib and .so files). I've packaged the resources folder following this page: How to create jar file with package structure? and I've installed the jar in my local maven repo following this page http://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html I've seen this page how to package resources in a leiningen project also but in this case it seems that the package is not used as clojure

Clojure: issues getting the symbol of a function in a looping context

為{幸葍}努か 提交于 2019-12-25 12:46:13
问题 Let's take that Clojure code: (defn ^{:test-1 "meta-test-1"} fn-key-1 [x] (eval nil)) (defn ^{:test-2 "meta-test-2"} fn-key-2 [x] (eval nil)) (def some-map {fn-key-1 "test-1" fn-key-2 "test-2"}) As you can see, the keys of my map are Symbols that refers to functions. I don't thing there is anything special there. As you can see, when defining the map the keys of my map are Symbols that refers to functions. However, when they are read by the reader, then they get resolved to the function

troubleshooting clojure web-app: connecting html and css for heroku deployment

落花浮王杯 提交于 2019-12-25 12:43:13
问题 I have two files, one html and one css. I have tried to turn them into a heroku app and even used the lein command to create a heroku friendly skeleton and plug these two files in, but cannot get it to work for the life of me. There is something very basic that I don't yet understand about how to coordinate a view with the back-end control. And the hello world tutorials aren't helping me because they do not show me how to do different things or explain what needs to change in my defroutes

How to pass a list of vector to clojure.jdbc/insert! in closure

南笙酒味 提交于 2019-12-25 09:41:05
问题 per the following link http://clojure.github.io/java.jdbc/#clojure.java.jdbc/insert! this function has parameters as (insert! db-spec table col-name-vec col-val-vec & col-val-vecs :transaction? true :entities identity) So it accept multiple vectors to be inserts as multiple rows. But if I have a list of vectors, and how to pass it to this function? (def rows (repeat 10 [ 1 2])) (clojure.jdbc/insert mydb test_table [:a :b] rows) ;; this doesn't work as rows is a list of vector ;; I could use