Questions tagged [clojure-contrib]

Extensions and enhancements to the Clojure libraries.

108 questions
1
vote
1 answer

Does Clojure have any functions similar to sow/reap from Mathematica?

Are there functions in the Clojure, which emulate the Mathemaica functions sow/reap? The main usage of sow and reap involve collecting expressions that were generated in the course of evaluation. Example) input in Mathematica: Reap[Sow[w =…
sunspots
  • 1,047
  • 13
  • 29
1
vote
2 answers

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…
DNNX
  • 6,215
  • 2
  • 27
  • 33
0
votes
2 answers

Check physical existence of files referenced in DB table

We have one rather large table containing documents info together with filepaths pointing to files on file system. After couple of years we noticed that we have files on the disk which are not referenced in DB table and vice-versa. Since currently…
zarko.susnjar
  • 2,053
  • 2
  • 17
  • 35
0
votes
1 answer

How do you append environment variables to a java clojure cli?

I have files which are created via clojure frontendapp.jar backendapp.jar and take an environment variable, APP_PORT What I want to understand is how do I pass variables to the jar files so that they run with the variable APP_PORT? My assumption…
0
votes
2 answers

Clojure throws error only when using 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…
tsm
  • 3,598
  • 2
  • 21
  • 35
0
votes
1 answer

How to show error on missing parameters for options?

I'm an absolute Clojure beginner and I'm trying to build a CLI app using the clojure.tools.cli library. My problem is that I can't show any error when an option is not provided with required parameter. What I want: $ java -jar test.jar -m…
Raj
  • 23
  • 1
  • 4
0
votes
1 answer

java.lang.StackOverflowError in clojure.java.data from-java

I have a Java class generated by Protocol Buffers called TextLine. When I instantiate the Java object with: (def tb (-> (TextLine/newBuilder) (.setText "this is a text line") (.build))) And then call: (from-java tb) I receive a…
frank
  • 501
  • 8
  • 21
0
votes
1 answer

How to use getInputStream() to get POST request data in Clojure. I am getting an NullPointerException in Reflector

This is my function to get the msg from email: (defn parse-message [request] (let [session (javax.mail.Session/getDefaultInstance (java.util.Properties.) nil) msg (javax.mail.internet.MimeMessage. session (.getInputStream…
0
votes
2 answers

clojure-contrib.jar import error

Command line is "D:\Progra~1\Java\jre6\bin\java.exe -jar D:\Old\Clojure\clojure.jar D:\Old\Clojure\clojure-contrib.jar" Following error appears: clojure.lang.Compiler$CompilerException: clojure-contrib.jar:0: Unable to resolve symbol: PK♥♦ in this…
DSblizzard
  • 4,007
  • 7
  • 48
  • 76
0
votes
1 answer

Clojure cmdline start use maven pom file

For example: If I specific the path ~/.m2/repository When I import some dependencies in cmd line like follow then it can find the jar location by my maven pom file. [yf@local]java -cp clojure-1.8.0.jar clojure.main Clojure 1.8.0 user=> user=>…
yunfan
  • 760
  • 1
  • 11
  • 24
0
votes
1 answer

Clojure normalize function runtime error

This code that I wrote gives me the error: java.lang.Long cannot be cast to clojure.lang.IFn which means that I am using a number where a function is expected. I think it has to do with the expt functions from clojure.math.numeric-tower but I am…
Cody
  • 3
  • 2
0
votes
1 answer

How to build clojure_contrib with Clojure v 1.6?

I've downloaded the current stable version of Clojure on my Macbook, which is 1.6. However, I only find the way to build clojure_contrib with clojure 1.3 or older. So how can I build it with clojure v1.6 ?
Alvin
  • 23
  • 5
0
votes
2 answers

clojure.contrib.sql syntax help: Can someone give me the syntax for deleting rows from a database?

Let's say I had a table called, "someTable" and I want to delete the row where column1 = "data1", column2 = "data2", etc... This is the code I have so far. (let [db-host "asdfgh.abc.roott.net" db-port 1234 db-name "ABCDE"] (def db…
user3745942
  • 193
  • 1
  • 2
  • 7
0
votes
2 answers

Writing the Lp norm function

I'm attempting to write the Lp norm function as to generalize the standard L2 norm (Euclidean distance) used. Here is what I have come up with so far, given how I had written the L2 norm: (defn foo [a b p] (reduce + (map (comp (map #(power a %)…
sunspots
  • 1,047
  • 13
  • 29
0
votes
2 answers

Raising elements in a vector to a power

I am trying to input a vector and parameter p, which in turn should raise each element of the vector to the power p. So far I have tried mapping the numeric tower function power, but that has proved unsuccessful. What would be the easiest way to…
sunspots
  • 1,047
  • 13
  • 29