clojure

Why Is String Formatting Causing a Casting Exception?

北战南征 提交于 2020-01-03 15:56:15
问题 Why does (String/format "%8s" (Integer/toBinaryString 6)) result in a java.lang.ClassCastException: java.lang.String cannot be cast to [Ljava.lang.Object casting exception? 回答1: I don't know Clojure, but I suspect that's trying to call the method as if it were the Java: String.format("%8s", Integer.toBinaryString(6)); but without the varargs support. I suspect you want: (String/format "%8s" (into-array Object (Integer/toBinaryString 6))) See this mailing list thread for more information from

Why did the designer make vector, map, and set functions in clojure?

随声附和 提交于 2020-01-03 13:58:51
问题 Rich made vector, map, and set functions, while list, and sequence are not functions. Why cannot all these collections be function to make it consistent? Further, why don't we make all these compose data as a function which maps position to it's internal data? If we make all these compose data as function then there will be only function and atom data in clojure. This will minimize the fundamental elements in that language right? I believe a minimal, best only 2, set of fundamental elements

Why did the designer make vector, map, and set functions in clojure?

扶醉桌前 提交于 2020-01-03 13:57:27
问题 Rich made vector, map, and set functions, while list, and sequence are not functions. Why cannot all these collections be function to make it consistent? Further, why don't we make all these compose data as a function which maps position to it's internal data? If we make all these compose data as function then there will be only function and atom data in clojure. This will minimize the fundamental elements in that language right? I believe a minimal, best only 2, set of fundamental elements

Automating Leiningen local dependency management

匆匆过客 提交于 2020-01-03 13:39:49
问题 I am using a local maven repository to house some code I am using to develop a project. I have cited this repository in my project.clj file, and am now able to rely on local jars in this way (how to do this in a previous question of mine). Since I am actively developing these projects, I have my project.clj file looking for the LATEST version. But, in order to update a dependency, I still have to increment the version number of that dependency and then run lein install to build it to the

Automating Leiningen local dependency management

*爱你&永不变心* 提交于 2020-01-03 13:39:16
问题 I am using a local maven repository to house some code I am using to develop a project. I have cited this repository in my project.clj file, and am now able to rely on local jars in this way (how to do this in a previous question of mine). Since I am actively developing these projects, I have my project.clj file looking for the LATEST version. But, in order to update a dependency, I still have to increment the version number of that dependency and then run lein install to build it to the

Lisp / Clojure: Is it a good idea to write function generating macros?

旧街凉风 提交于 2020-01-03 09:25:07
问题 This question asks to create a Clojure macro to generate several functions. We figured out a way to do this but were stuck with the question of "Is this a good idea?". My initial reaction is not really , for two reasons You then have functions that are not defined in your code, and this can complicate understanding your code quite a bit! (Imagine somebody has a problem with one of your functions and looks at the source code only to not find it anywhere). It is better to factor out the

Clojure/postgresql: How do I see the exception when an error is in the db?

余生颓废 提交于 2020-01-03 07:21:33
问题 When using clojure with postgresql, whenever a statement I issue is malformed in some way or otherwise rejected by the db itself I get something like the following error: java.sql.BatchUpdateException: Batch entry 0 drop schema public cascade was aborted. Call getNextException to see the cause. How can I call getNextException so that I can see what I did wrong? Where do I call it from? 回答1: See this link on clojure/jdbc showing how to drop a table with Clojure/JDBC. It also shows you how to

How do I change directory in command line with Clojure?

偶尔善良 提交于 2020-01-03 07:19:05
问题 What I'm looking for is this kind of command line interaction at the Windows command line: C:\temp1>clj some_script.clj C:\temp2> Where some_script.clj contains something like: (cd "c:\\temp2") So the question is - how do I implement the function cd? Have experimented with clojure.java.shell, but it does not look like the lib I need. This might be a simple question, the problem might be that I'm not fluent in Java?! 回答1: You can't do this in Java, so you can't do it in Clojure. See Changing

How do I change directory in command line with Clojure?

怎甘沉沦 提交于 2020-01-03 07:18:38
问题 What I'm looking for is this kind of command line interaction at the Windows command line: C:\temp1>clj some_script.clj C:\temp2> Where some_script.clj contains something like: (cd "c:\\temp2") So the question is - how do I implement the function cd? Have experimented with clojure.java.shell, but it does not look like the lib I need. This might be a simple question, the problem might be that I'm not fluent in Java?! 回答1: You can't do this in Java, so you can't do it in Clojure. See Changing

Clojure and HBase: Iterate Lazily over a Scan

血红的双手。 提交于 2020-01-03 03:36:09
问题 Lets say I want to print the output of an hbase table scan in clojure. (defmulti scan (fn [table & args] (map class args))) (defmethod scan [java.lang.String java.lang.String] [table start-key end-key] (let [scan (Scan. (Bytes/toBytes start-key) (Bytes/toBytes end-key))] (let [scanner (.getScanner table scan)] (doseq [result scanner] (prn (Bytes/toString (.getRow result)) (get-to-map result)))))) where get-to-map turns the result into a map. It could be run like this: (hbase.table/scan table