In Clojure, how do I get the name of the namespace in which variables and functions are named? For example, improving the following:
(ns my-ns)
(def namespace-name "my-ns")
The problem with the above is that if I want to change the name of my-ns, I have to change the definition of namespace-name as well
...
Hi
Several repl (like ruby irb) had some very useful features like use the arrows keys to "rewind" and "forward" the commands, but when i try to do the same with clojure, it only print garbage (I suspect it print the code of the key). How i could activate this feature in clojure?
...
can i somehow find all functions/macros that take a specific type of parameter ?
for example, what function accepts a Namespace object as parameter ?
(this is because i can create a namespace and store it in a var, but i don't know where i could use that var; what function might i pass that var to ?)
here is some code:
user=> (def wo...
Hi guys,
According to you, which language do you think would be the best for implementing monads (Python/Ruby/LISP)?,also can anyone tell me some possible uses of monads (please give examples),like exceptions?
Thanks in advance
...
Does anybody want to answer my question linked here how-to-pass-a-typed-collection-from-clojure-to-java
, by providing a clear example, for the rest of us who are trying to sneak clojure in their existing java stack?
...
Has anyone integrated with Google Latitude (or any Google API, for that matter) with Clojure and can point me to a working example? I'm trying authenticate to the Google Latitude API and running into all sorts of problems, for example a "Token Invalid" error from Google- nothing else- after logging in for the User Approval URI.
Thanks!
...
How would I type hint this to get rid of the remaining reflection calls?
(def B
(amap ^"[[D" A i ^"[[D" B
(amap ^doubles (aget A (int i)) j ^doubles row
(* 2 (aget row (int j))))))
There's two reflection calls left, but I don't know how to get rid of them.
...
I'm looking for the ability to have the REPL print the current definition of a function. Is there any way to do this?
For example, given:
(defn foo [] (if true "true"))
I'd like to say something like
(print-definition foo)
and get something along the lines of
(foo [] (if true "true"))
printed.
...
Coming from a background in Clojure, I am taken with the potential that its pre-/post-conditions provide as a basis for design by contract:
;; sqr.clj
(defn sqr [n]
{:pre [(not= 0 n) (number? n)]
:post [(pos? %) (number? %)]}
(* n n))
(sqr 10)
;=> 100
(sqr 0)
; Assertion error
Is there a similar pre/post capability in Commo...
Is there a way I can set a div background color in hiccup? Here is what I tried so far, with no result:
[:div {:background-color "#003366"} (escape-html rest)]
In the html, I see <div background-color="#663366"> which I do not believe is the correct format for color.
Is there a way to do this in hiccup?
...
I need to make a decision about a string based on the first character, and I have a method defined in this way:
(defn check-first [string]
(case (get string 0)
"+" 1
"-" 2
3
))
Currently it always returns 3 even when the string starts with those characters. What am I doing wrong? Also, is there a more elegant way to ...
So regular clojure repl works fine, (read-line) collects input, then echos it. Using lein repl though, never echoes any input characters, nor does it ever allows me to return from any stdin reading commands.
I'm sure it has something to do with rebinding in, but was wondering if there is a workaround/fix?
Thanks.
...
My current method: if there's a function that I know has an bug, I copy bits and pieces of it into the REPL and evaluate to see if the output is what I expect. To set it up, I have to def the arguments to the function as dummy input. Not terribly time-consuming, but I know there's a more efficient way.
Any suggestions?
...
Hi,
I tried to migrate a project from clojure 1.1 to 1.2 because of the new protocols introduced in 1.2. But when I try to :use clojure-contrib.duck-streams I get a warning about 'spit' which already exists in clojure.core. The same problem with clj-time.core and 'extend' which also exists in clojure.core.
Can anyone explain what would...
Can this Java code be translated to Clojure code that's as fast or nearly as fast?
I've been able to get simpler functions like adding two arrays to run at reasonable speeds with type hinting, but I couldn't get Clojure to do what the functions below do at all in a reasonable amount of time using either Java interop or Incanter matrice...
I'm trying to connect my Google App Engine webapp to the Google Latitude API using OAuth. I have it working in my dev environment, but when I try to test the app using Google's dev_appserver.sh, I get the following error:
java.security.AccessControlException: access denied (java.net.SocketPermission www.googleapis.com resolve)
Is this...
Are there any Clojure http libraries that use the java.net.URLConnection class? Reason I'm asking is because that's the only accepted way to make http connections on Google App Engine, according to the docs.
I'm currently using com.twinql.clojure.http for my GET requests, but I don't think that uses the right interface because I'm getti...
How does JVM type erasure help Clojure? Can Clojure exist without it? What would happen if the JVM had reified types? That is, how would Clojure change?
...
I'm looking for a way to visualize a 2d java array that's being updated in a simulation written in clojure the same way I would use imshow in matplotlib to visualize a numpy array.
What's the best way to do this? Alternatively I could save the arrays to disk and visualize it in matplotlib. What would be the best way to go about that?
...
I'm currently looking into Clojure and Incanter as an alternative to R. (Not that I dislike R, but it just interesting to try out new languages.) I like Incanter and find the syntax appealing, but vectorized operations are quite slow as compared e.g. to R or Python.
As an example I wanted to get the first order difference of a vector
u...