clojure

How do I pull `static final` constants from a Java class into a Clojure namespace?

I am trying to wrap a Java library with a Clojure binding. One particular class in the Java library defines a bunch of static final constants, for example: class Foo { public static final int BAR = 0; public static final int SOME_CONSTANT = 1; ... } I had a thought that I might be able to inspect the class and pull these ...

testing Clojure in Maven

I am new at Maven and even newer at Clojure. As an exercise to learn the language, I am writing a spider solitaire player program. I also plan on writing a similar program in Scala to compare the implementations (see my post http://stackoverflow.com/questions/2571267/modern-java-alternatives-closed). I have configured a Maven directory ...

Executing a dynamically bound function in Clojure

I'd like to pre-store a bunch of function calls in a data structure and later evaluate/execute them from within another function. This works as planned for functions defined at namespace level with defn (even though the function definition comes after my creation of the data structure) but will not work with functions defined by let [na...

(partial apply str) and apply-str in clojure's ->

If I do the following: user=> (-> ["1" "2"] (partial apply str)) #<core$partial__5034$fn__5040 clojure.core$partial__5034$fn__5040@d4dd758> ...I get a partial function back. However, if I bind it to a variable: user=> (def apply-str (partial apply str)) #'user/apply-str user=> (-> ["1" "2" "3"] apply-str) "123" ...the code...

How do I get the set of all letters in Java/Clojure?

In Python, I can do this: >>> import string >>> string.letters 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' Is there any way to do something similar in Clojure (apart from copying and pasting the above characters somewhere)? I looked through both the Clojure standard library and the java standard library and couldn't find i...

Which classic Lisp books are going to be ported to Clojure?

Which classic Lisp books will be ported to Clojure? Does this involve the complete text or only the code files? ...

Comparing Clojure books

Currently [April 5 2010] there is (afaik) one completed Clojure book available: Programming Clojure by Stuart Halloway. Two are being written and partially available at Manning: The Joy of Clojure by Fogus and Houser Clojure in Action by Amit Rathore Another one is about to be published in May: Practical Clojure (The Definitiv...

Is there an equivalent for the Zip function in Clojure Core or Contrib?

In Clojure, I want to combine two lists to give a list of pairs, > (zip '(1 2 3) '(4 5 6)) ((1 4) (2 5) (3 6)) In Haskell or Ruby the function is called zip. Implementing it is not difficult, but I wanted to make sure I wasn't missing a function in Core or Contrib. There is a zip namespace in Core, but it is described as providing...

IllegalAccessError and proxy

Hi there, I'm translating this code to Clojure. As you can see, I have to extend the class ArthurFrame, yet I'm getting an IllegalAccessError everytime I use (proxy [ArthurFrame] [] ...). Any idea why? Here is the class's source. Thanks! EDIT: Here is the full error stack for running (proxy [ArthurFrame] []) on the REPL. EDIT 2: Ac...

Can I use swank-clojure with the clojure 1.2 master branch?

I'm happily using swank-clojure, installed via elpa. But I'd like to do some work with deftype, defprotocol, etc., which aren't aren't available in clojure 1.1. To use my own class paths, I'm using the excellent suggestion by Rick Moynihan in the stackoverflow question about setting custom classpaths, which was to set up a script like:...

How to Reload files upon save when using swank+leiningen+emacs

I'm looking to set up slime+lein-swank to reload source files referenced from the repl when i save the file. currently i do this: edit file save file switch to repl (use :reload-all 'com.package.namespace) test stuff I want to not have to remember to do step 4. ...

Clojure agents consuming from a queue

I'm trying to figure out the best way to use agents to consume items from a Message Queue (Amazon SQS). Right now I have a function (process-queue-item) that grabs an items from the queue, and processes it. I want to process these items concurrently, but I can't wrap my head around how to control the agents. Basically I want to keep a...

Learning Clojure - What should I know about Java and more.

Hello, I have started learning Clojure recently, my main programming language is Ruby and I have no Java experience whatsoever. Which Java standard classes are a must to know when working with Clojure? Obviously Clojure doesn't come with a wrapper for everything and a lot of functionality is provided by Java's libraries. There's...

can rest framework like jersey be used in clojure instead of compojure

Hi , iam newbie to clojure, just curious as to can i use jersey REST api as REST webframework for clojure? all along i see people talking about compojure? if you can provide me any resource or reasoning that would be great Thank you ...

Why does Clojure hang after having performed my calculations?

Hi all, I'm experimenting with filtering through elements in parallel. For each element, I need to perform a distance calculation to see if it is close enough to a target point. Never mind that data structures already exist for doing this, I'm just doing initial experiments for now. Anyway, I wanted to run some very basic experiments w...

How to go about reading a web page lazily in Clojure

I and a friend recently implemented link grabbing in my Clojure IRC bot. When it sees a link, it slurp*s the page and grabs the title from the page. The problem is that it has to slurp* the ENTIRE page just to grab the link. How does one go about reading a page lazily until the first </title>? ...

A regex to match a substring that isn't followed by a certain other substring.

I need a regex that will match blahfooblah but not blahfoobarblah I want it to match only foo and everything around foo, as long as it isn't followed by bar. I tried using this: foo.*(?<!bar) which is fairly close, but it matches blahfoobarblah. The negative look behind needs to match anything and not just bar. The specific language I...

What's the easiest way to parse numbers in clojure?

I've been using java to parse numbers, e.g. (. Integer parseInt numberString) Is there a more clojuriffic way that would handle both integers and floats, and return clojure numbers? I'm not especially worried about performance here, I just want to process a bunch of white space delimited numbers in a file and do something with them...

Embedding swank-clojure in java program

Based on the Embedding section of http://github.com/technomancy/swank-clojure, I'm using the following to test it out. Is there a better way to do this that doesn't use Compiler? Is there a way to programmatically stop swank? It seems start-repl takes control of the thread. What would be a good way to spawn off another thread for...

log4j: Change format of loggers configured in another library.

Using clojure, I've been able to successfully setup log4j very simply by using this log4j.properties file, and including log4j in my classpath. # BEGIN log4j.properties log4j.appender.STDOUT=org.apache.log4j.ConsoleAppender log4j.appender.STDOUT.layout=org.apache.log4j.PatternLayout log4j.appender.STDOUT.layout.ConversionPattern=%d{MMd...