Questions tagged [clojure-contrib]

Extensions and enhancements to the Clojure libraries.

108 questions
4
votes
2 answers

Manipulating java objects from clojure

am new at clojure and would like to interact with java objects using clojure. If I have well understood, one can reach this interaction using defprotocol. What I concretely try to do is the following: 1- I have following java class package…
Horace
  • 1,198
  • 2
  • 17
  • 31
3
votes
1 answer

How do I eval a clojure data structure within the context of a namespace?

I'm writing a clojure app for internal use, and I want the config file to be in clojure too. I have defined a few macros to make writing the config file easier, but when I try to eval the data from the config file, it cant find my macros. This…
Chris
  • 455
  • 5
  • 10
3
votes
1 answer

Monolithic Contrib for Clojure

https://github.com/clojure/clojure-contrib This link of clojure asks to use Monolithic Contrib with clojure 1.3. From where can i get jar of Monolithic Contrib or jar is same as clojure-contrib?
vikbehal
  • 1,486
  • 3
  • 21
  • 48
3
votes
3 answers

Why does my Clojure import fail?

I'm running Clojure 1.3 with contrib 1.1 in IntelliJ. My program consists of a single line (use 'clojure.contrib.prxml) I get the following error upon running Exception in thread "main" java.lang.RuntimeException: java.lang.NoSuchMethodError:…
deltanovember
  • 42,611
  • 64
  • 162
  • 244
3
votes
2 answers

using clojure.contrib.strint with a string defined elsewhere

I'm new to clojure, and I'm trying to use clojure.contrib.strint to build a URL. for example I might use this for a google search: (def search_base_url "http://www.google.com/search?hl=en&q=~{query}") (defn search_url [search_term] (let [query…
Johnny Brown
  • 1,000
  • 11
  • 18
3
votes
2 answers

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…
sa125
  • 28,121
  • 38
  • 111
  • 153
3
votes
2 answers

Create line segment from two points in 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)…
Matthew Boston
  • 1,320
  • 10
  • 24
3
votes
1 answer

reading large command output with clojure

I'm using the sh function from the clojure.java.shell command to read the very large output of a command. The output is around 60meg of data. I keep getting java.lang.OutOfMemoryError. Is there a way to open a sort of pipe that would let me read…
nkassis
  • 5,285
  • 2
  • 21
  • 22
3
votes
3 answers

Importing clojure functions from jars

I'm playing around with Clojure, and I can't figure out how to import a function from clojure-contrib.jar. Working from this answer, I'm doing the following: Running the REPL like so: java -cp clojure.jar:clojure-contrib.jar clojure.main Then…
Steve Armstrong
  • 5,252
  • 7
  • 32
  • 43
3
votes
3 answers

Circularly shifting nested vectors

Given a nested vector A [[1 2 3] [4 5 6] [7 8 9]] my goal is to circularly shift rows and columns. If I first consider a single row shift I'd expect [[7 8 9] [1 2 3] [4 5 6]] where the 3rd row maps to the first in this case. This is implemented…
sunspots
  • 1,047
  • 13
  • 29
3
votes
1 answer

Mapping functions over nested vectors in Clojure

I'm trying to write a more general map function for Clojure, but am unable to map a function over a nested vector. In particular the the map should admit a parameter n, which allows level specification of the nesting. Here's what I've written so…
sunspots
  • 1,047
  • 13
  • 29
3
votes
2 answers

Clojure function for first differences, second differences,...,nth differences

Inputting a vector I'd like to write a function that gives successive differences between elements. Ideally the function should input a vector x and parameter n that designates nth difference. Sample in the form [x n] Input 1: [16 10 8 6 4 2] 1 (1…
sunspots
  • 1,047
  • 13
  • 29
3
votes
1 answer

Clojure pattern matching for vectors

I'd like to write a function that takes vectors [& x] and applies a test to pairs of elements. Outputting a vector of elements the test deemed identical and a vector of nil elements. My first thought is to take the vectors and flatten them. (defn…
sunspots
  • 1,047
  • 13
  • 29
3
votes
4 answers

Combining vectors by index

I am looking to write a function which inputs two vectors of length n, i.e. [:a :b :c :d :e :f] [1 2 3 4 5 6]. Outputting one vector of length 2n [:a 1 :b 2 :c 3 :d 4 :e 5 :f 6]. However, if the second vector being input doesn't match the length…
sunspots
  • 1,047
  • 13
  • 29
3
votes
2 answers

How can you "parameterize" Clojure Contrib's test-is?

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…
Robert Campbell
  • 6,848
  • 12
  • 63
  • 93