17,775 questions
1
vote
1
answer
61
views
Cannot invoke "java.lang.Character.charValue()" because "x" is null
This is the code fragment of the error:
(defn end-render
[fb]
(let [width (get-in fb [:dimen :width])
height (get-in fb [:dimen :height])
msfbo (:msfbo fb)
fbo (:fbo fb)]
...
2
votes
1
answer
114
views
How to write an accumulative recursive function in J without looping
At the risk of asking a question with an obvious solution: if I have a function in J that takes two arguments and returns two arguments and I want to accumulate the answer's second argument and to use ...
1
vote
0
answers
81
views
Clojure problems in resolving .local server address inside private network
First of all thanks in advance for any help, this is the first time I'm setting up a system like this, so a few points are not clear and might be written in bad form (and that's why I'm here).
...
1
vote
1
answer
86
views
How to type hint a float array?
This code
(GL33/glUniform2fv ^int (location shader "offsets") ^float [] offsets)
produces this error:
No matching method glUniform2fv found taking 3 args for class org.lwjgl.opengl.GL33
I'...
3
votes
0
answers
121
views
Fast lazy sort & deduplication over multiple sorted lazy sequences in Clojure
I implemented a few lazy sort & merge functions that are used heavily in my ReBAC authorization library, EACL, to lazily "merge" & deduplicate ~1M datoms emitted from Datomic's d/...
1
vote
1
answer
76
views
Intellij & Clojure LSP - Getting Started
I'm just trying the Clojure LSP plugin in Intellij IDEA Community without knowing anything about Clojure or the plugin.
My goal is to start learning Clojure.
I installed the plugin and clojure-lsp via ...
0
votes
0
answers
41
views
Parse nested metadata
One thing I like about metadata is that I can organise functions across namespaces. E.g.:
(defn ^{:category 1} a-function []
(do-stuff))
(->> (ns-interns 'this.namespace)
vals
(map ...
0
votes
1
answer
57
views
How to include a file with shadow-cljs/inline, but preprocess it first?
Shadow-cljs has a resource loader that can include literal files into the Clojurescript code
(ns app.my
(:require
[shadow.resource :as rc]))
(rc/inline "file.txt")
I need a macro that ...
0
votes
1
answer
87
views
Complains about a non-existent PersistentArrayMap
In this function I get an exception:
(defn ball-collision?
[ball brick]
(let [^org.joml.Vector3f ball-pos (:position ball)
^org.joml.Vector3f brick-pos (:position brick)
^org.joml....
0
votes
0
answers
42
views
Error on invocation of reitit.swagger/create-swagger-handler
I am trying to make a sample web application on clojure that uses reitit and exposes its structure via swagger. To that end i have added code that handles request for "/swagger.json" as ...
1
vote
2
answers
112
views
Avoid garbage when using atoms
Consider this code snippet which calculates the delta time since the last frame:
(defn game-loop
[window game]
(let [last-frame (atom (GLFW/glfwGetTime))]
(while (not (GLFW/...
1
vote
1
answer
92
views
Appending to a vector in a map, but referencing the map only once
Consider this map:
(def my-map {:a-vec []})
Now I want to append some value to a-vec:
(assoc my-map :a-vec (conj (:a-vec my-map) 17))
What I don't like about this is that I name both the map and the ...
1
vote
0
answers
126
views
My clojure project.clj can't be loaded in intellij with Cursive, it interfere with proxy settings
When enabling Cursive in Intellij 2024.03 it throws:
Error reading C:\myprocect-path\project.clj
class com.intellij.credentialStore.OneTimeString cannot be cast to class java.lang.String (com.intellij....
0
votes
1
answer
110
views
Clojure implementation about five times slower than Java implementation
This is the Java code:
public static FloatBuffer createInterleavedVertexBuffer(AIMesh mesh) {
FloatBuffer buffer = BufferUtils.createFloatBuffer(mesh.mNumVertices() * 8);
for (int i = 0; i <...
2
votes
1
answer
60
views
How to correctly integrate java source into a leiningen project?
This is my java source file:
package main;
class ModelLoader {
public static void foo() {
System.out.println("foo");
}
}
which is located at src/main/java/ModelLoader.java.
...
3
votes
1
answer
63
views
Accessing the window from a menu item in Cljfx
How can I access the main window (:stage) from a menu click event in Cljfx? I need it for two reasons: to open a file chooser, and to resize the window.
A minimal example:
(ns a
(:require [cljfx.api ...
0
votes
1
answer
49
views
Cannot call a particular java method listed in clojure.reflect/reflect
I am having no luck calling advanceExact in various Lucene DocValues subclasses, for example:
user> (.advanceExact doc-values 1)
Execution error (IllegalArgumentException) at user/eval24512 (REPL:...
0
votes
1
answer
90
views
Reading a 3D model with lwjgl-assimp failes in Clojure
This is my Clojure code:
(ns learnopengl.mesh-model
(:import [org.lwjgl.assimp Assimp AINode AIMesh]))
(defn read-model
"read a 3D model from a file"
[path]
(let [scene (Assimp/...
-2
votes
2
answers
59
views
io/resource "file.txt" always nil (CLI) [closed]
Working from CLI:
(ns something
(:require [clojure.java.io :as io]))
(io/resource "file.txt")
=>nil
(slurp "file.txt")
=>"content of file"
Why doesn't io/...
-1
votes
2
answers
127
views
Systemtray Icon with clojure, cljfx and FXTrayIcon(Java)
Would like to have the equivalent of this in clojure, using the cljfx-library.
FXTrayIcon icon = new FXTrayIcon(stage, getClass().getResource("someImageFile.png"));
icon.show();
Starting ...
1
vote
5
answers
150
views
How does this reduce work, when the anonymous function takes 2 parameters?
Using clojure, how does this reduce work, when the anonymous function takes 2 parameters?
(defn better-symmetrize-body-parts
"Expects a seq of maps that have a :name and :size"
[asym-...
0
votes
0
answers
30
views
Unable to eval region using monroe (nREPL)
I am writing a non-Clojure nREPL server. To test it, I need a language-agnostic nREPL client. I have been using monroe, however I am being thwarted by an error when I attempt to evaluate selected text:...
2
votes
1
answer
96
views
MemoryStack: Out of stack space
I'm using LWJGL MemoryStack together with JOML like this:
(ns learnopengl.transformations
(:import [org.joml Vector3f Matrix4f]
[org.lwjgl.system MemoryStack]))
(def memory-stack (...
0
votes
0
answers
39
views
toucan2 insert-returning-instance! is not returning the inserted record in mysql however works for postgres, any configuration needed in mysql?
According to their documentation https://cljdoc.org/d/io.github.camsaul/toucan2/1.0.511/api/toucan2.insert#insert-returning-instances!, insert-returning-instance! should return the inserted record ...
1
vote
2
answers
328
views
How to run Clojure REPL using IntelliJ and Cursive plugin
I am desperately trying to set up a working environment for Clojure 1.12.0.1488, using IntelliJ 2024.3, Cursive's plugin 2025.1.1-343 and openJDK 24.
I am using VoidLinux based on kernel 6.12.28_1, ...
2
votes
3
answers
130
views
Converting a vector to a map in Clojure
I'm having a problem with a little function that's supposed to count nodes and leaves in a tree. This is what it looks like:
(defn count-tree
"Count nodes and leaves in a tree as produced by ...
2
votes
1
answer
89
views
How does clojure decide to which type a function belongs?
Consider this snippet:
(def vertices [
-0.5 -0.5 0
0.5 -0.5 0
0 0.5 0])
(def vertex-buffer (doto (BufferUtils/createFloatBuffer (count vertices))
(dorun (map #(.put (float %...
2
votes
2
answers
102
views
Uberjar with JavaFX compiled by Leiningen doesn't have runtime components
I have an extremely simple Clojure project that uses JavaFX 21.0.7; it's just one file, and all it's meant to do (at the moment) is display a stage with a scene consisting of an empty pane:
(ns ...
0
votes
1
answer
67
views
How to create a glfwKeyCallback
I've been trying to follow this tutorial. This is my callback:
(def cb (proxy [java.lang.Object GLFWKeyCallbackI] []
(invoke [window keycode _ action _]
(when (and (= keycode ...
0
votes
1
answer
56
views
updating map paths that are not present using traversy/lens in clojure
consider i have map r as below -
{:a1 {:foo {:xyz "xyz" :abc []} }
:a2 {:bar {:xyz "xyz" :abc []} }
:a3 {:baz {:xyz "xyz" :abc []} }
:a4 {:bax {:xyz "xyz"}}
...
1
vote
1
answer
63
views
Unable to match glfwCreateWindow
I'm trying to follow this tutorial and can't seem to correctly translate this line:
window = glfwCreateWindow(300, 300, "Hello World!", NULL, NULL);
This is what I've tried:
(let [window (...
0
votes
1
answer
102
views
Clojure mutant – can't kill a surviving mutant in binary search
I'm writing a classic binary search function in Clojure and testing it with the mutant mutation testing library.
My tests work fine in terms of correctness, but mutation testing reports one surviving ...
1
vote
1
answer
81
views
Very cryptic error message: Execution error (UnsupportedOperationException)
This is the error:
Execution error (UnsupportedOperationException) at bucket_drops_screen_extension.main_menu.proxy$java.lang.Object$Screen$e6e56cf1/show (REPL:-1).
show
This is my code:
(defn screen
...
1
vote
1
answer
127
views
How to create Clojure-style loop/recur macro using syntax-case in Guile Scheme?
I'm learning syntax-case macro system. This is what I have so far:
(define-syntax loop
(lambda (x)
(syntax-case x ()
[(_ (var val x ...) body)
(with-syntax ([recur (datum->syntax ...
1
vote
1
answer
118
views
Clojure Kit: JWT Authentication
I'm trying to implement a REST API using Kit. My routes are defined as follows:
(defn api-routes [_opts]
["/auth/login" {:post auth/login}]
["/auth/checked" {:get (wrap-auth ...
0
votes
2
answers
56
views
How to access .class? (java interop)
This is the java code I'm trying to implement in clojure:
manager.load("data/mytexture.png", Texture.class);
I've tried this:
(.load "resources/bucket.png" (.class Texture))
...
1
vote
1
answer
114
views
Creating Java Interface With Annotations, Immediately Usable in REPL
I am trying to do a few things at once with a Clojure macro but it's not working. I want to either learn how to fix it or understand why it is impossible.
I want to:
Create a Java interface in ...
0
votes
2
answers
49
views
java interop: No matching method found
I'm trying to call a method of a java library:
(.draw (:sprite-batch @resources) (:bucket @resources) 0.0 0.0 1.0 1.0)
And get this error:
Execution error (IllegalArgumentException) at bucket-drops....
0
votes
1
answer
93
views
How to use clj-kondo to get all java imports in a clojure file
I have use care where I have to process several clojure projects and find the imports of java libraries in each clojure namespace
I an invoking clj-kondo from my code for each .clj file as follows:
(...
1
vote
1
answer
57
views
What's the best way to "fork" a `ref`?
For example:
(let [!a (ref 1 :validator odd?)]
(dosync
(alter !a (comp inc inc))
(let [!b (fork-ref !a)]
(alter !b (comp inc))))) ;; should throw IllegalStateException
Of course it's ...
0
votes
1
answer
134
views
How do I import a Java project from GitHub into a Clojure project?
I want my Clojure program to "look out at the world" through the camera. I found a Github project that does the work and is even written in Java. I got it to work using a 3-line piece of ...
1
vote
2
answers
155
views
How do you validate a string representing a local date in malli?
I'm trying to use https://github.com/metosin/malli?tab=readme-ov-file#malliexperimentaltime
Here is what I have
(ns foobar.core
(:require [malli.core :as m]
[malli.registry :as mr]
...
0
votes
0
answers
39
views
How does the idiom (some #{:fred} coll) work? [duplicate]
From the documentation for some:
Returns the first logical true value of (pred x) for any x in coll,
else nil. One common idiom is to use a set as pred, for example
this will return :fred if :fred ...
0
votes
1
answer
64
views
for doesn't produce output when there is also loop/recur in the same function body [duplicate]
Consider this code snippet:
(defn foo []
(let [line (apply str (repeat 2 \.))
lines (into [] (repeat 2 line))]
(for [x lines] (println x)) ; this doesn't print
(loop [remaining [[1 2]...
1
vote
1
answer
122
views
Papertrail API returns 401 Unauthorized in Babashka script despite valid token
I'm using Heroku with the Papertrail add-on to manage my server logs. However, I'm not satisfied with Papertrail’s UI and would like to pull logs locally using their API. To do this, I'm writing a ...
3
votes
1
answer
102
views
Clojure - why can I call (Integer/MAX_VALUE) as a function?
An example probably explains it best. Why does the 2nd and 3rd examples work?
Integer/MAX_VALUE
=> 2147483647
(Integer/MAX_VALUE)
=> 2147483647
((((((Integer/MAX_VALUE)))))) ; wtf?
=> ...
1
vote
3
answers
160
views
How to I read the system clock (in Clojure) as quickly as possible?
I need an integer timestamp and want to circumvent the overhead of creating a Java Date object.
Is there such a thing from Clojure?
I want the datetime now in (long? double?) integer form, not ...
0
votes
3
answers
107
views
pmap not performing as expected
This is my code:
(defn calculate [operators operands]
(loop [index 0
equation (get operands 0)]
(if (< index (count operators))
(recur (inc index) (list (get operators index) (...
1
vote
1
answer
82
views
What's the purpose of a datomic multiple head rule? What's the difference between those kind of rules and a or-clause query?
I'm studying Datomic and I got stuck in Multiple Head Rules.
In Datomic Documentation, it's said that a Multiple Head Rule is a rule that has multiple "heads" and each head has a different ...
1
vote
1
answer
76
views
Using a future efficiently
Given this line of code:
(filter #(is-valid? %) input)
is-valid? is a somewhat heavy operation. input has a size of maybe a thousand. To speed things up I thought to run is-valid? in parallel:
--> ...