Clojure-api: Single main CLj for several API managers

The below is my app project.clj (defproject clojure-my-app-api "0.1.0-SNAPSHOT" :description "FIXME: write description" :url "http://example.com/FIXME" :license {:name "Eclipse Public License" :url "http://www.

Picking & ldquo; Random & rdquo; elements of a vector

I am looking to pick out random, will obviously be pseudorandom, elements from a vector. The function would have an input, call it r, that would select the number of elements to be selected. Also, the vector, call it v, would also have to be an input

Conversion of arbitrary depth entries into vectors

Take a function which inputs a set, set of sets, collection, nested vector with collections buried within, etc. So, the inputs sometimes are not of the same type. How would one go about converting such input into a nested vector structure? In the fir

Several regular expressions in Clojure

What is the optimal way to couple multiple regular expressions within a Clojure function? I believe the function would start out as such: (defn foo [x] (re-seq #"some means to combine multiple regex") but am not clear if this is will work, or th

Constructing a vector embedded in Clojure

My goal is to build a nested vector of dimension n consisting of a single element p. As an example let me choose n=2 and p=1, so the output would be: [[1 1] [1 1]] Probably, you want something like this: (defn square-matrix [n p] (->> p (repeat n) (

Building Clocks

If I wanted to build a table in Clojure of vector duplicates, I'd write: (take 2 (repeat [1 2 3])) But how would I expand this notion of a table function to build something like: Input 1: [a^2 2 6 2] where a^2 is some input function, 2 is min value,

How to rewrite Ruby's Array (x) in Clojure?

In Ruby, there is Kernel#Array method, which acts like this: Array([1, 2, 3]) #=> [1, 2, 3] Array(1..5) #=> [1, 2, 3, 4, 5] Array(9000) #=> [9000] Array(nil) #=> [] In other words, it converts nil to empty array, non-collections to singleton a

How can I depend on each library clojure contrib?

I used to like to include all of clojure.contrib, and require all the libraries. This makes find-doc useful as a discovery tool. Nowadays (clojure 1.4) clojure.contrib is split into many sub-libraries. And that rather spoils my scheme, and it also me

Pass the sequence as an argument instead of multiple arguments

How can I/should I pass a single sequence as an argument to a function which expects multiple arguments? Specifically, I'm trying to use cartesian-product and pass it a sequence (see below); however, when I do so the result is not the desired one. If

How to run the Clojure file?

How can I run a clojure file/script, which uses clojure-contrib, from the command line? My (winodws) machine has clojure-1.2.1.jar and clojure-contrib-1.2.0.jar on the classpath. Note: I can start the REPL with: java clojure.mainand I can execute *.c

Loading clojure-contrib

I'm new to the whole JVM thing, and trying to play with clojure. I'm attempting to load clojure-contrib and failing: # in bash $ java -cp /path/to/clojure.jar:/path/to/contrib.jar clojure.main # in REPL user=> (require 'clojure.contrib.math) nil user

Clojure returns an error only when using the namespace

I've started working on a chess game in Clojure, but am having trouble with my namespace. At the top of my file, I have (ns chess.core (:require clojure.contrib.str-utils2)) and also define several functions, including to-string, which turns the symb

Create a line segment from two points at Clojure

What's the best way to go about doing this? Here's what I've got so far (defn line-segment [start end] (let [x-direction (abs (- (first end) (first start))) y-direction (abs (- (last end) (last start)))] (cond (= 0 x-direction) (something ...) (= 0 y

How to convert a sequence into a byte [] in Clojure?

I need to write raw bytes to the file. I do it with: (.write (FileOutputStream "/path") bytes) ...where bytes must be of type byte[]. Please note it cannot be Byte[]. I tried to convert my sequence with both (bytes) and/or (into-array) functions

Insertions in Zipper trees on XML files in Clojure

I'm confused as how to idiomatically change a xml tree accessed through clojure.contrib's zip-filter.xml. Should be trying to do this at all, or is there a better way? Say that I have some dummy xml file "itemdb.xml" like this: <itemlist>

HTML format Compojure

I'm relatively new to Clojure and a complete HTML/Compojure virgin. I'm trying to use Compojure to create static pages of HTML using a function similar to this: (defn fake-write-html [dir args] (let [file (str dir *file-separator* *index-file*) my-ht

How can you & ldquo; set & quot; The test of Clojure Contrib?

Both Junit and TestNG provide mechanisms for iterating over a collection of input parameters and running your tests against them. In Junit this is supported via the Parameterized annotation, while TestNG uses @DataProvider. How can you write data-dri

Build a Clojure application with a command line interface?

I just started w/ Clojure (coming from Ruby) and I would like to build an small app with a command-line interface. How do I handle input/output to a CL? I noticed that there is a clojure.contrib.command-line, but documentation is slim. http://github.