Extensions and enhancements to the Clojure libraries.
Questions tagged [clojure-contrib]
108 questions
0
votes
1 answer
Appending an element at nth index
I'm working on a function, which takes a vector (possibly nested vector) as input along with some quantity y and index n. Essentially the function would append y after the nth element in the vector and adjoin the remaining elements. So far I have…

sunspots
- 1,047
- 13
- 29
0
votes
1 answer
Flipping elements in Clojure
If I input a vector and wanted to flip the elements' order, I'd write
(reverse [1 2 3])
Now, how would I generalize this idea to be able to input nested vectors and flip the order of elements? Given a matrix A the function should reverse the…

sunspots
- 1,047
- 13
- 29
0
votes
3 answers
Building a nested vector 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]]

sunspots
- 1,047
- 13
- 29
0
votes
2 answers
clojure contrib logging to file
Hi I have tried logging with clojure contrib but to no avail.
Its clojure 1.1
(ns com.class.main.service
(:gen-class)
(:require (clojure.contrib [logging :as log])))
(log/info "Hello world")
I have put a log4j.jar file in my bin and a…

sqwale
- 554
- 3
- 24
0
votes
1 answer
Trying to use a Clojure-Contrib Graph function
I am having trouble getting the function fixed-point from Clojure-Contrib Graph to run. Admittedly the problem is trivial. I have tried to use the techniques shown in loading clojure-contrib but am still running into trouble.
Note: I am using…

sunspots
- 1,047
- 13
- 29
0
votes
2 answers
Testing vectors and nested vectors in Clojure
Is there a way in Clojure to test a vector and see if it's nested, i.e. a way to test [:a :b :c :d] vs. [[:a :b] [:c :d]]?
I've tried the test
(vector? [:a :b :c :d])
true
but it remains true for nested vectors as well,
(vector? [[:a :b] [:c…

sunspots
- 1,047
- 13
- 29
0
votes
1 answer
Does Clojure map include level specification?
In trying to write a mapping function that applies a function, i.e inc, dec, etc. to the elements of an input vector. The output is a vector with the function applied to each element and an indexing element.
Here is a sample of what I'm trying to…

sunspots
- 1,047
- 13
- 29
0
votes
1 answer
Expanding the map function to handle nested segments
I am simply trying to rename the map function in Clojure to gain better exposure to arbitrary inputs. The function I wrote has problems with the number of args being passed. Namely,
(defn new-map [f [& x]]
(map f x))
Moreover, the end goal is…

sunspots
- 1,047
- 13
- 29
0
votes
3 answers
Building tables in clojure
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…

sunspots
- 1,047
- 13
- 29
0
votes
1 answer
Writing a tuples function that permutes all possible n-tuples
I'm working towards a tuples function, which takes collections and a parameter n. The parameter designates the number of indices the generated vector should have. The function then permutes all possible n-tuples of the elements in the collection.
So…

sunspots
- 1,047
- 13
- 29
0
votes
2 answers
Looking to write a spanning function with optional step input
I'm stuck trying to write a Clojure function that takes a span from a collection or vector.
For example I'd like to manipulate a collection such as
(:a :b :c :d :e :f :g :h)
by taking the second element through the fifth in steps of two.
Thus,…

sunspots
- 1,047
- 13
- 29
0
votes
4 answers
Modifying the function count to return zero for strings and zero for numbers
I'm writing a function that can input strings, numbers, arrays, Java Collections and Maps. The constraints are the output for both strings and numbers should be zero.
The Clojure function count does everything I need, except handle the constraints.…

sunspots
- 1,047
- 13
- 29
0
votes
0 answers
Don't know how to create ISeq from: Symbol (logging.clj:13)
I have tried using require to get external libraries into my working name space but I keep getting the error
"java.lang.RuntimeException: java.lang.IllegalArgumentException: Don't know how to create ISeq from: Symbol (logging.clj:13)"
Below is my…

sqwale
- 554
- 3
- 24
0
votes
1 answer
check if attribute with a specific value is present in zip/node using zip-filter library or another one
am new at clojure and would like to know how to check if an attribute with a specific value is present in a zip/node using the zip-filter library.
Let us say I have the following xml content in a file named "myfile.xml"
…

Horace
- 1,198
- 2
- 17
- 31
0
votes
1 answer
Polymorphic I/O utility functions for Java 7 file I/O
Is there a library for I/O utility functions for Java 7 file I/O akin to clojure.java.io available in Clojure Contrib or elsewhere?
Specifically, I'm interested in the utilities which could provide a Clojure-friendly, coercive API that make using…

yakshaver
- 2,472
- 1
- 18
- 21