Tagged Questions
2
votes
0answers
54 views
Using Overtone in Jython / Clojure Dependencies in Jython
I'm currently working on a project that primarily uses Jython, but makes use of interop (using rik0's pyclj solution) with Clojure to utilize the Overtone library. Typically, leiningen is the primary ...
4
votes
1answer
69 views
Is assoc behavior inconsistent?
assoc may throw IndexOutOfBoundsException when the index is, well, out of bounds, as in:
user=> (assoc [] 1 nil)
IndexOutOfBoundsException ...
2
votes
3answers
62 views
clj-ssh / JSch unable to load library 'c' on Windows
I've added clj-ssh as a dependency to a Leiningen project, and I can (use 'clj-ssh.ssh) but calling (ssh-agent {}) gives the error
UnsatisfiedLinkError Unable to load library 'c': The specified ...
5
votes
3answers
70 views
How can I debug a non-responsive server, when the profiler can't collect samples?
I have been having occasional problems with a server I wrote. It's in Clojure, but I don't think that matters, and we can pretend it's in Java. Anyway, it works fine for hours at a time, but goes into ...
1
vote
1answer
34 views
Clojure and HBase: Iterate Lazily over a Scan
Lets say I want to print the output of an hbase table scan in clojure.
(defmulti scan (fn [table & args] (map class args)))
(defmethod scan [java.lang.String java.lang.String] [table start-key ...
1
vote
2answers
63 views
Clojure: Return an Iterator for a java for loop
Lets say I have a for loop in Java:
for(Foo foo : foos){ do_something() }
Now lets say I want to translate this list iteration to idiomatic clojure. Whats the best way? I want to return ...
0
votes
1answer
72 views
Clojure Equivalent of Java ConcurrentHashMap using atom map
Inspired by this blog post on Event Sourcing, I am wondering if it is possible to implement a Clojure structure equivalent of a Java ConcurrentHashMap. Basis this
post by Rich to the Clojure maling ...
0
votes
2answers
51 views
does Clojure on Hotspot require any non-FOSS components
When I use Clojure with the (Sun/Oracle) Hotspot VM, what other software components are required, at a minimum, by Clojure? Are all those (minimal) components Open Source?
I see that the Hotspot VM ...
3
votes
3answers
76 views
Can example be modified to return a value?
Given the following sample from JNotify, I am having a little trouble understanding implements. Is it valid Java syntax for class Listner to implement JNotifyListener's methods -- fileRenamed, ...
0
votes
1answer
88 views
How to convert java.sql.Timestamp to UTC-based string?
When you call .toString on a java.sql.Timestamp instance, you get back a formatted string in your local time zone. I want a formatted string based off of UTC, like the one that I see in the ...
3
votes
3answers
168 views
Is there a Java version of Clojure's or Scala's persistent immutable vector?
That is, immutable but data sharing with effectively O(1) indexing.
2
votes
1answer
95 views
IntelliJ IDEA plugin development in other JVM languages
Is it possible to use other JVM languages such as Scala and Clojure for developing an IntelliJ IDEA plugin? Or do we have to use Java for this purpose? I could find no pointers on this on web, hence ...
0
votes
1answer
60 views
Clojure Java Interop - reference to field … can't be resolved
I am working on a clojure project where I want to create a class in Java and then instantiate that class and call a method from within my clojure code.
My Java code is located in ...
0
votes
1answer
55 views
How do I solve this error in clojure: java.lang.Exception: Too many arguments to def (NO_SOURCE_FILE:130)
I get
java.lang.Exception: Too many arguments to def (NO_SOURCE_FILE:130)
when i test the map below. Please help me resolve the error.
Here is my code:
(def test_data
"Create map test data ...
0
votes
2answers
195 views
generate “create table” script from jdbc (clojure/java)
Does anyone know if anything is available to generate a "create table script" FROM a database through jdbc using clojure or java?
I could just fetch from the system tables or information schema, but ...
2
votes
2answers
89 views
Invoke method of a class which name is generated dynamically
I'm writting simple application in Clojure. My task is to get (from user) fully qualified class name (Java class) which implements Runnable interface and invoke start method. My problem is how run ...
3
votes
1answer
53 views
Error in Clojure java.lang.Exception: transaction rolled back: d != clojure.lang.Keyword (NO_SOURCE_FILE:0)
Here is my code:
(defn tbl_email_data
{:new-acc 1
:email "[email protected]"
:token "pa55P0rt"})
(defn create-online-test-data[data_values]
(with-connection
...
0
votes
2answers
123 views
emacs & clojure compiling error
I am a beginner in clojure & emacs.
I am following tutorial for clojure & emacs on clojure-doc.org .
After I created my test project with lein, started nrepl in emacs and
edited ...
0
votes
1answer
150 views
beginners emacs / clojure compiling error
I'm going through clojure & emacs tutorial from clojure-doc.org, and when compiling
the test as suggested, i get following output in emacs nrepl:
clojure.lang.Compiler$CompilerException: ...
4
votes
3answers
117 views
Timing primes generation in Clojure
This will be a question to people really familiar with Clojure.
I wanted to write simple primes checking function in Java and in Clojure, and compare execution times.
So here is my code in Java:
...
0
votes
1answer
116 views
How to concatenate static methods from a Java class object?
I'm trying to call the randomVector method from the Vec2D class found here http://toxiclibs.org/docs/core/
Here is my code:
(def particles (new ArrayList))
(defn add-particle []
(dotimes [i 100]
...
1
vote
1answer
79 views
Making thumbnails in Clojure
I'm running the following command in my terminal to run the code stored in the following file:
java -cp clojure.jar clojure.main thumbmaker.clj
Where the content of thumbmaker.clj is (this code has ...
4
votes
2answers
120 views
Java/clojure: Multiple character delimiter, and keep the delimiter
I'm working on a project in clojure, which can interop with any java classes, so the answer to my question could be for either java or clojure.
Basically I need to be able to split a string into ...
2
votes
1answer
96 views
Clojure REPL not launching at Windows command prompt
I have placed the clojure-1.4.0.jar path (C:\clojure-1.4.0\clojure-1.4.0.jar) in my CLASSPATH environment variable. Now when I try to launch the REPL from the command line with the following code:
...
1
vote
1answer
72 views
NPE in clojure.lang.Compiler when trying to load a resource
I already reported this problem in CLJ-1172, but didn't receive any feedback from Clojure team. Maybe someone here can tell me what's wrong. This is my code:
import clojure.lang.Compiler;
...
0
votes
2answers
61 views
Clojure - “Exception in thread ”main“ java.lang.ClassCastException: seesaw.core.proxy”
I'm currently learning Clojure, and I haven't worked with any Lisp dialect before.
So, trying to make a simple GUI test, I get a ClassCastException in seesaw.
core.clj file:
(ns veg-gui.core)
(use ...
0
votes
1answer
85 views
Could not locate Clojure resource on classpath
I am trying to access some of my clojure functions in my Java code (I am using Eclipse and CounterClockWise). Firstly, I was not sure how to do it? But then I found some answer here.
I am using ...
2
votes
2answers
75 views
Create and then write to a text file what is printed to the REPL
How, from a clj file, to take whats is outputted to the REPL by the function "print" and put it all in text file ?
Is there a way to create a new, empty, text file and put it in the project directory ...
1
vote
2answers
109 views
How to access clojure functions in Java?
I am quite a newbie to Clojure. I am trying to build my computational units (pure functions) in Clojure and bind all these functions into a program using Java.
For accessing Clojure in Java, I have ...
5
votes
1answer
67 views
Round-tripping a Java class through the Clojure printer and reader
I have a Java class Vector2 that I'd like to persuade to "play nicely" with the Clojure reader.
(def a (vec2 1 2))
(print-str a)
=> "#<Vector2 [1 2]>"
Ideally I'd like the class to print ...
6
votes
1answer
220 views
Java -> Clojure -> Java
I am trying to use Clojure as a scripting language from a host Java program. The idea being that the end user will be able to write Clojure scripting code that will call a domain-specific Java API. At ...
1
vote
1answer
79 views
Creating an uberjar for a project that uses MySQL and SQLServer
I'm trying to build a project in clojure that takes data from a
Microsoft SQL Server database, and pushes it to a MySQL database.
The project runs fine using lein run, but when I package it into an
...
11
votes
2answers
1k views
Clojure Performance For Expensive Algorithms
I have implemented an algorithm to calculate the longest contiguous common subsequence (not to be confused with longest common subsequence, though not important for this questions). I need to squeeze ...
0
votes
3answers
90 views
List the classes / interfaces that a Clojure protocol has been extended to
Suppose I have a Clojure protocol:
(defprotocol Foo
(bar [x]))
I know this protocol may have been extended (with extend-protocol or extend-type) to a number of Java classes and/or interfaces.
...
1
vote
2answers
57 views
Clojure fails when calling amap on a primitive array
On ClojureDocs, it mentions that aset is only workable on array of refrence java types. But it does not mentions about the usage of amap.
(reduce
(fn [#^doubles sum #^doubles prob]
(println ...
6
votes
3answers
114 views
How to cache file handles?
I have an application that wants to keep open many files: periodically it receives a client request
saying "add some data to file X", and it would be ideal to have that file already opened, and the ...
2
votes
1answer
79 views
Unable to call an instance method from Clojure.
I'm completely new to Java and clojure. But with previous experience in common lisp, I thought I would give clojure a try. I'm unable to figure out few very basic things.
This is the actual Java ...
1
vote
1answer
116 views
Is a Bytecode viewer or a decompiler best for understanding JVM language code [closed]
I'm puzzled by some performance of Clojure and Scala on the JVM, and I'm wondering what the best way to understand the cryptic functional code. Should I learn to grok the bytecode, or use a profiler ...
3
votes
2answers
100 views
Conventional place to store files used by Clojure (or JVM) apps
I have an application written in Clojure. This application is helping write other applications (e.g., as a plugin for leiningen). To do so, it needs a place to write some files, which are used ...
0
votes
3answers
65 views
check if argument to ProcessBuilder is a valid command
I'm working a a Clojure library to simplify subprocess management for a project of mine. It essentially wraps Java's ProcessBuilder in a more Clojuric way. One thing I'd like to do is to catch any ...
18
votes
9answers
1k views
What can I do to speed up this code?
I'm trying to learn Java, Scala, & Clojure.
I'm working through the Project Euler problems in the three languages. Listed below is the code for problem #5 (http://projecteuler.net/problem=5) as ...
1
vote
4answers
175 views
Clojure Java Interop Error: Illegal Argument Exception: NO MATCHING CONSTRUCTOR FOUND
I found this related question on Stack Overflow, but it didn't really answer my question.
I have a Java application that I've packaged as a JAR file. I also have a Clojure application that I've ...
0
votes
1answer
67 views
Removing reflection warning for .clone
How do I remove the reflection warning from this Clojure code that is attempting to call a Java clone method:
(defn clone-foo [m]
(.clone m))
=> Reflection warning, NO_SOURCE_PATH:2 - reference ...
6
votes
1answer
220 views
Will I be able to use Clojure functions as Lambdas in Java 8?
I use a number of libraries in Clojure that produce higher order functions that conform to the "clojure.lang.IFn" interface.
It has multiple arity overloads, I.e. the interface looks something like:
...
2
votes
1answer
66 views
Piping a subprocesses output directly to stdout (java/clojure)
I'm looking for a way to start up a subprocess in clojure (java is fine to) and have the output of it get sent directly to stdout in real-time. The closest I've been able to find is the Conch library ...
0
votes
1answer
270 views
Embedded jetty with vaadin 7
I'm trying to set up a clojure environment for vaadin 7. With vaadin 6 I could use AbstractApplicationServlet which provides the application class. I can then do in clojure repl (use 'foo.bar.core ...
-1
votes
4answers
309 views
Assembly Programming on the JVM?
I was kind a curious if it was possible to do assembly programming in a similar fashion of using NASM in C.
After quick Google search to see if it was possible to do assembly language programming ...
16
votes
2answers
1k views
Clojure performance really bad on simple loop versus Java
Spoiler alert, this is problem 5 of Project Euler.
I am attempting to learn Clojure and solved problem 5, but it is a couple orders of magnitude slower (1515 ms in Java versus 169932 ms in Clojure). ...
3
votes
3answers
171 views
java mixed with clojure in maven and eclipse
i created a sample polyglot program. i have a sensor and a robot implemented in java and AI implemented in clojure. and i can't connect maven properly
--src/main/java/clojuretest
...
2
votes
0answers
73 views
Which errors to handle in clojure REST+disk-I/O app?
I have a server application which, somewhat simplified, periodically takes measurements via a rest-api from a not beefy-enough-server. The values should be cached locally (and are ...