clojure

Confused by "let" in Clojure

I just started playing with Clojure, and I wrote a small script to help me understand some of the functions. It begins like this: (def *exprs-to-test* [ "(filter #(< % 3) '(1 2 3 4 3 2 1))" "(remove #(< % 3) '(1 2 3 4 3 2 1))" "(distinct '(1 2 3 4 3 2 1))" ]) Then it goes through *exprs-to-test*, evaluates them all, and ...

How do I set up the Clojure classpath in Emacs after installing with ELPA?

I'm trying to add paths to my classpath in the Clojure REPL that I've set up in Emacs using ELPA. Apparently, this isn't the $CLASSPATH environment variable, but rather the swank-clojure-classpath variable that Swank sets up. Because I used ELPA to install Swank, Clojure, etc., there are a ton of .el files that take care of everything in...

Declare array as return type in gen-class method declaration in Clojure.

How to declare an array in method declaration in gen-class? (ns foo.bar (:gen-class :methods [[parseString [String Object] Object]])) That works fine. But the return type is really an array. How I can declare that so Java can understand it? ...

leiningen - how to add dependencies for local jars?

Hi, I want to use leiningen to build and develop my clojure project. Is there a way to modify project.clj to tell it to pick some jars from local directories? I have some proprietary jars that cannot be uploaded to public repos. Also, can leiningen be used to maintain a "lib" directory for clojure projects? If a bunch of my clojure pro...

clojure type conversion string to symbol

in clojure i have vector ["myfn1" "myfn2" "myfn3"] how can i call functions named "myfn1" ... using strings from that vector ...

How do I get "rainbow parentheses" in emacs?

Hello StackOverflowers, I would like rainbow parens for editing Clojure in Emacs and since VI does this I assume that in Emacs it should be something like M-x butterfly or something :) ...

leiningen: missing super-pom

if I enable eith the clojure-couchdb or swank-clojure then lein deps fails because org.apache.maven:super-pom:jar:2.0 is missing :dependencies [[org.clojure/clojure "1.1.0-master-SNAPSHOT"] [org.clojure/clojure-contrib "1.0-SNAPSHOT"] [clojure-http-client "1.0.0-SNAPSHOT"] [org.apache.activem...

Create a HTML table from nested maps (and vectors)

I'm trying to create a table (a work schedule) I have coded previously using python, I think it would be a nice introduction to the Clojure language for me. I have very little experience in Clojure (or lisp in that matter) and I've done my rounds in google and a good bit of trial and error but can't seem to get my head around this style...

Clojure open source projects

Do you know of any good open source projects written in Clojure? (or just ANY at all :)) I'm learning the language and wold like some code to read as I go. Thanks, Alex ...

Best unit testing framework for Clojure?

What is the best unit testing framework for Clojure? I prefer a more BDD style framework. Thanks, Alex ...

How to find a web hosting service for running Compojure

I am very interested in building a website using Clojure and Compojure, like so: http://briancarper.net/blog/deploying-clojure-websites However, due to my limited experience with the Java environment and Java culture, I am not sure where to begin when shopping for a web-hosting service. Do I simply need to find a service that gives me...

Mutating XML in Clojure

Clojures clojure.xml/parse, clojure.zip/xml-zip and clojure.contrib.zip-filter.xml/xml-> are excellent tools for pulling values out of xml, but what if I want to change the xml (the result of clojure.zip/xml-zip) based on what I learn from xml-> "queries" and write the result back out as xml? I would have expected that (clojure.contrib....

How can I use one file from my project in another file?

Simple question. I'm new to Clojure. How can I use one file from my project in another file? Basically how can I include, import, or require another file? Not from libraries but fro my own code. Thanks, Alex ...

Roundtripping xml in Clojure using clojure.xml/parse and clojure.xml/emit

Below roundtrip produces invaild xml as the result is not escaped correctly, i.e. the attribute values contain ' instead of apos;. Am I doing somthing wrong or is this a bug? (ns xml-test (:require [clojure.xml :as xml]) (:require [clojure.zip :as zip])) (def test-xml "<?xml version="1.0" encoding="UTF-8"?> <main> <item attr='&apos...

Is there a colored REPL for Clojure?

I'd like to get a colored REPL for clojure code, similar to what you can do with IRB for Ruby. Are there any libraries or settings for user.clj that provide automatic coloring of the REPL? Example IRB: ...

Can I add fields to clojure types?

Clojure structs can be arbitrarily extended, adding new fields. Is it possible to extend types (created using deftype) in a similar way? EDIT: For the benefit future visitors, as Brian pointed out below, this feature is subject to change. ...

Why are so many new languages written for the Java VM?

There are more and more programming languages (Scala, Clojure,...) coming out that are made for the Java VM and are therefore compatible with the Java Byte-Code. I'm beginning to ask myself: Why the Java VM? What makes it so powerful or popular that there are new programming languages, which seem gaining popularity too, created for it...

Getting Vars to bind properly across multiple files

I am just learning Clojure and am having trouble moving my code into different files. I keep detting this error from the appnrunner.clj - Exception in thread "main" java.lang.Exception: Unable to resolve symbol: -run-application in this context It seems to be finding the namespaces fine, but then not seeing the Vars as being bound.....

When should clojure keywords be in namespaces?

In clojure, keywords evaluate to themselves, e.g.: >>:test :test They don't take any parameters, and they aren't bound to anything. Why then, would we need to qualify keywords in a namespace? I know that creating isa hierachies using derive requires namespace qualified keywords. Are there any other cases where there is a clear nee...

Calculating rgb vals for BufferedImage

I am using following snippet to build a 32 bit integer to use with setRGB of BufferedImage (bit-or (bit-shift-left a 24) (bit-or (bit-shift-left r 16) (bit-or (bit-shift-left g 8) b))) after writing colors reading them back reveals wrong colors is there a fault in my logic? ...