It seems as though I'm having problems accessing Integer.parseInt in comp. I can access it normally like this:
user=> (Integer/parseInt "123")
123
But if I put it in comp, I get an error:
user=> (def vect-to-int (comp Integer/parseInt (partial apply str)))
java.lang.Exception: Unable to find static field: parseInt in class java.lang...
Hello,
Taking an example of Fibonacci Series from the Clojure Wiki, the Clojure code is :
(def fib-seq
(lazy-cat [0 1] (map + (rest fib-seq) fib-seq)))
If you were to think about this starting from the [0 1], how does it work ? Would be great if there are suggestions on the thought process that goes into thinking in these terms.
...
Reading a recent question I identified the function being discussed
(def fib-seq
(lazy-cat [0 1] (map + (rest fib-seq) fib-seq)))
as holding onto the head of a sequence, but it occurred to me re-reading my answer that I had glossed over the details like they were obvious, so I went back to clarify and came up short. I know that fi...
I created a basic hello world class in eclipse with clojure and counterclockwise and I'm able to compile it with clojure no problem.
(ns ca.ckovacs.test.helloWorld
(:gen-class))
(defn -main
[greetee]
(println (str "Hello " greetee "!")))
I see that this generates three classes in my /classes folder:
helloWorld__init.class...
How can I be notified when a process I did not start ends and is their a way to recover its exit code and or output? the process doing the watching will be running as root/administrator.
...
I'm having trouble finding good advice and common practices for the use of namespaces in Clojure. I realize that namespaces are not the same as Java packages so I'm trying to tease out the conventions in Clojure, which seem surprisingly hard to determine.
I think I have a pretty good idea how to split functions into clj files and eve...
Clojure comes with some basic ui apps that let you inspect objects. The generic "inspect" ui has buttons on the top for List, Table, Bean, Line, Bar, Prev, Next, etc but as far as I can tell they don't do anything. I looked at the source and they seem functionless from the code as far as I can tell. Am I crazy?
(use 'clojure.inspecto...
I am new to clojure and I have tried to compile it last night but I couldn't seem to do it and I have no idea. I am on windows and don't know much about java. I just want a stand-alone file that I can give to my friends. (I know they need java) Can anyone help?
...
I'm trying to write a function that checks if a character is within a certain hexadecimal range.
I'm trying the code shown below:
(def current \s)
(and (>= current (char 0x20)) (<= current (char 0xD7FF)))
I get the following error:
java.lang.ClassCastException: java.lang.Character cannot be cast to
java.lang.Number (NO_SOURCE_FILE...
Say I have a collection of maps:
(def coll #{{:name "foo"} {:name "bar"}})
I want a function that will add an id (a unique number is fine) to each map element in the collection. i.e.
#{{:id 1 :name "foo"} {:id 2 :name "bar"}}
The following DOES NOT WORK, but it's the line of thinking I currently have.
(defn add-unique-id [coll]
(m...
I've noticed that some libraries such as clojure-twitter use special vars (the ones intended for dynamic binding that are surrounded by asterisks) for oauth authentication. You save your authentication in a var and then use (with-oauth myauth ..). I think this is a very nice solution to this sort of problem, because you can rebind the au...
Hi,
Is there a detailed explanation for results obtained on evaluating the following on REPL.
(.PI Math)
gives
IllegalArgument Exception
while
(. Math PI)
evaluates to
3.141592653589793
...
I'm used to Java code, with its long descriptive names, and with lots of temporary variables used only to give a name to some return value. This kind of code is very easy to understand even after a year break.
When using Lisp, however, I can't understand things like "what is in the 3rd position of this list" the next day, or even next h...
I am moving to Emacs to work on Clojure/Lisp.
What is all the information I need to setup on Emacs to be able to do the following?
automatic matching/generation of corresponding closing brackets
autoindent Lisp/Clojure style, not C++/Java style
Syntax highlighting
Invoking REPL
To be able to load a part of code from file into the REPL ...
Here is a bit of example code:
(deftype Deck52 [suits] :as this
DeckOfCards
(check-empty []
(Deck52. (apply hash-map
(apply concat (remove (-> nil?)
(for [[key val] suits]
(if (emp...
Contrived example to illustrate:
(def nest1 {:a {:b {:c "foo"}}})
(def nest2 {:d {:e "bar"}})
If I wanted to conj these nests at arbitrary levels, I could explicitly do this:
(conj (-> nest1 :a :b) (-> nest2 :d)) ; yields {:e "bar", :c "foo"}
(conj (-> nest1 :a) (-> nest2 :d)) ; yields {:e "bar", :b {:c "foo"}}
But what if I wante...
Hi,
Can someone suggest articles that explain the concept of Homoiconicity, especially using Clojure. Why is it that Clojure is homoiconic but its hard to do that in other languages such as Java ?
...
Hi,
Quoting in clojure results in non-evaluation. ':a and :a return the same result. What is the difference between ':a and :a ? One is not evaluated and other evaluates to itself... but is this same as non-evaluation ?
...
Hi!
Is there a way to mimic a this variable in something like (def foo {:two 2 :three (inc (:two this))})? Even better would be something like (def foo {:two 2 :three (inc ::two)}). I was told that there is a library that does exactly this, but I can't really find anything similar.
Thanks!
...
Hi!
I'm not being able to import a particular class (FinanceService) from a jar. All the others work fine, including the inner-class FinanceService$Versions. I'm getting a NoClassDefFound exception, and I'm not sure how to proceed.
This exception occurs, paraphrasing an answer I've found here, when the source was successfully compiled,...