clojure

Local dependencies in Leiningen without creating a Maven repo?

时光毁灭记忆、已成空白 提交于 2020-01-22 19:28:12
问题 I'm building a Compojure web application, and I'd like it to use functions from another Clojure project I wrote. I'm not at all familiar with Maven, and from what I've heard, it has a very steep learning curve. Unfortunately, everything I've seen suggests using a private Maven repo as a dependency and doesn't suggest an alternative. I'd really like to avoid struggling with Maven if possible. Does anyone know of an alternative? I'm currently using the latest version of Leiningen. 回答1: If the

flip order of passed arguments

我只是一个虾纸丫 提交于 2020-01-22 18:58:08
问题 Is there a idiomatic / built-in way to flip the argument order that is passed to a function in Clojure? As I do here with the definition of a helper function: (defn flip [f & xs] (apply f (reverse xs))) (vector 1 2) ; [1 2] (flip vector 1 2) ; [2 1] 回答1: A flip function does exist in other functional languages, but it's easy enough to do in Clojure as well, and you've already done it! There are other ways to do it as well. And here is a discussion about it from the Clojure mailing list. 回答2:

purpose of clojure reduced function

孤人 提交于 2020-01-22 17:36:58
问题 What is the purpose of the clojure reduced function (added in clojure 1.5, https://clojure.github.io/clojure/clojure.core-api.html#clojure.core/reduced) I can't find any examples for it. The doc says: Wraps x in a way such that a reduce will terminate with the value x. There is also a reduced? which is acquainted to it Returns true if x is the result of a call to reduced When I try it out, e.g with (reduce + (reduced 100)) , I get an error instead of 100. Also why would I reduce something

Running Java bytecode on the Android - Sun JVM on top of DalvikVM

杀马特。学长 韩版系。学妹 提交于 2020-01-22 05:56:06
问题 Since both the java implementation ( OpenJDK ) and Android's virtual machine DalvikVM are opensource it must be possible to implement Sun's JavaVM on top Google's DalvikVM. This would make it possible to run JVM based apps and languages ( Clojure, Jython ) out-of-the-box on the android. Is there an ongoing effort to produce such an implementation of the Sun JVM? 回答1: The OpenJDK makes use of native code so it would be a non-trivial port... there is at least one VM (JikesRVM) that is written

Creating the most basic Scala project with Maven?

不羁的心 提交于 2020-01-20 18:47:11
问题 I use Maven 3 to create a new Scala project. As far as I understand, the way to create a new project with Maven is by: mvn archetype:generate Maybe I'm missing out something, but I couldn't find even one option that offers the simplest Scala project (like the one received by lein new app ... for Clojure, for example). Any help here? 回答1: You should be able to use mvn archetype:generate . You can choose, e.g., org.scala-tools.archetypes:scala-archetype-simple . You need to put in the number

A finite possibly non-deterministic state machine with dwell durations

こ雲淡風輕ζ 提交于 2020-01-17 06:24:28
问题 after posting a somewhat ambiguous question, I believe I have nailed that what I am wondering (I am a complete novice in FSMs). I would like to simulate a state space using finite state machines (possibly non-deterministic automata i.e. multiple next-state transitions allowed) in clojure. This is essentially my problem: Suppose we have these states Q={flying,cycling,running,driving} and we have the state durations for each during an average day D={120,30,30,60} - where for the sake of

JavaFX font face dialog in Clojure

被刻印的时光 ゝ 提交于 2020-01-17 04:12:47
问题 I'm building a Clojure program that includes an option dialog where the user can select the font used in an editor. Just like many other programs, I would like to present the user with a ComboBox where the dropdown list displays the font names in the font itself (e.g. 'Calibri' is displayed in the Calibri font, 'Arial' is displayed in Arial, and so on.) In the past in Java, I have used a cell factory to customize the appearance of each cell in the list. My translation into Clojure is not

Eclipse Kepler hangs when trying to debug Clojure project

旧巷老猫 提交于 2020-01-16 18:10:47
问题 Installed Eclipse-Kepler on a Windows 8 box. Clojure and Leiningen already installed. Installed Counterclockwise. Started up, created test Clojure project, ran without debugger, and ran successfully under debugger. Messed with it a bit more, was in and out of the debugger several times. After one debugging session got "an error" (yes, I know I should have written it down, but failed to do so. Take pity upon the soul of this poor sinner...). After that every debugging session I tried to start

Using LevelDB in a ring/compojure webapp

梦想与她 提交于 2020-01-16 18:06:52
问题 I am am trying to setup LevelDB in a ring/compojure app, and looking for an idiomatic way to to access the opened db descriptor into each request. For example: (defn -main "I don't do a whole lot ... yet." [& args] (println "Opening LevelDB file in db/main") (with-open [main-db (db/open "db/main")] (println "Running server on port 3000") (run-jetty #'web/app {:port 3000}))) How do you access the main-db descriptor into the request handlers? ie.: (defroutes handler (GET "/test" [] (db/put main

Does Ring request {:scheme :https} guarantee a HTTPS connection?

左心房为你撑大大i 提交于 2020-01-16 03:44:11
问题 If the Ring request map key :scheme has value of :https , is it guaranteed that a HTTPS connection has been established and there were no certificate errors? 回答1: This is probably a question that relates to whatever servlet container you're using rather than ring. ring-servlet populates the :scheme key by getting a value from the HttpServletRequest: :scheme (keyword (.getScheme request)) The servlet specification has only this to say about getScheme : Returns the name of the scheme used to