Questions tagged [clojure]

Clojure is a Lisp dialect for the Java Virtual Machine. Its main features include a software transactional memory system for coherent updates to data structures, transparent access to Java libraries, a dynamic REPL development environment, runtime polymorphism, and built-in concurrent programming constructs.

48 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
16
votes
0answers
410 views

Shepard Tone stream generation in Clojure

This is my work to generate an infinite Shepard Tone. It is written in Clojure and works by generating repeating streams of incrementing frequencies, converting those to values on a sine wave and then ...
14
votes
0answers
196 views

Tracking the bounding box of a map

Context I have a bunch of data points that look roughly like this: ...
11
votes
0answers
400 views

Idiomatic way to implement `tail -f` in clojure

Disclaimer: This is just an educational task to learn how to program in clojure and switch brain to immutable state-way of developing (the provided snipped has some unused variables which I didn't ...
6
votes
0answers
398 views

Translating CFRM algorithm from Java to Clojure and improving performance

Counterfactual Regret Minimization is an algorithm that can be used to find the Nash Equilibrium for games of incomplete information. I have tried to adapt the exercise from here to Clojure. You can ...
5
votes
0answers
92 views

Clojure BrainF*** Interpreter

Since I want to try writing my own language at some point, I wanted to have some experience writing an interpreter. BrainFuck is the simplest language I (kind of) know, so I decided to try writing an ...
5
votes
0answers
76 views

Python-style object library for Clojure

Background I am authoring pulley.objective, an Open Source library that provides an object system inspired by Python's object model. I have some features ...
4
votes
0answers
72 views

Macro that allows for Linear Problem notation to create Genetic Algorithm fitness functions

As a side toy project for my Genetic Algorithm, I decided to try to create a macro that lets you use maximize: ... subject to: ... linear problem notation to ...
4
votes
0answers
58 views

Sierpinski Carpet using Seesaw

I decided to write a Sierpinski Carpet generator. This has been something I wanted to try since watching the Coding Train this summer. A screenshot of it in action with some experimental coloring: ...
4
votes
0answers
77 views

Evaluating RPG-formatted dice rolls with repeats in Clojure

My target was to write a function that takes a String as input, interprets it as a series of dice rolls, evaluates it and returns a series of integers. The input is in a form that is typical in table ...
4
votes
0answers
144 views

Attempt at Idiomatic Hangman in Clojure

I am pretty new to Clojure & am loving it so far. After going through a few resources, I decided to make a hangman game. I'm wondering how idiomatic is my code & where can I improve it ...
4
votes
0answers
118 views

Project Euler #14 in Clojure (finding long Collatz sequence chain)

I'm working on a Clojure implementation for Project Euler #14, which asks for the initial element, under 106, that produces the longest collatz-sequence chain. I'm trying to make use of every ...
4
votes
0answers
56 views

Basic declarative style to rotate and crop an image array

I wrote a couple of basic Clojure functions (practicing a declarative style) and I was looking to get some feedback on them. You can see all the code here. Is there anything I could improve on to ...
4
votes
0answers
119 views

Perform a contains-ignore-case with multiple search-tokens

I had a look on Stack Overflow etc. on how to perform a contains ignore case with n given strings. Most answers suggested using regex for this task. Although it's a valid option, I prefer doing upper-...
3
votes
0answers
45 views

Brainfuck NASM compiler in Clojure

I've made a simple brainfuck compiler, I feel like my code is unreadable and messy, how can I improve it? src/core.clj ...
3
votes
0answers
174 views

Forest Fire Cellular Automata

I stumbled on the idea of a Forest Fire simulating cellular automata, and decided to try making a version using a full Seesaw UI (a Clojure wrapper over Java's Swing). A short sample of it running is ...
3
votes
0answers
46 views

SQL-like syntax to sort and filter a collection

I was helping someone on SO with an assignment to create a macro that accepts an SQL-like syntax, and optionally sorts and filters a collection. I realized that while their instructor is insisting on ...
3
votes
0answers
176 views

Functional Merge Sort

I just finished this Merge Sort in Clojure, structured according to ex. 22-26 of this workshop. The main question I have can be answered without spending time understanding the code: ...
3
votes
0answers
416 views

Filling a Boot with CIDER

I'm trying to put together a workflow for building Clojure applications with Boot in CIDER. To test this workflow, I've written a small example application using Seesaw. My project structure looks ...
3
votes
0answers
289 views

single-threaded socket server

I wrote a basic Clojure single-threaded socket server, mostly following Java examples; in particular I'd appreciate feedback on three things, how I handle mutable state (I/O, managing connections). ...
3
votes
0answers
188 views

Back-propagation implementation

I've written an implementation of the back-propagation algorithm in Clojure (here). This is my first attempt at Clojure where the code totals more than ten lines and so it is not very idiomatic; ...
2
votes
0answers
33 views

My implementation of Clojure's assoc-in

This is my implementation of Clojure's assoc-in function. I am looking for tips on making it more idiomatic and in general, better. ...
2
votes
0answers
50 views

Why does my Clojure implementation of Conway's Game of Life run so much slower than my Java implementation?

I'm trying to learn Clojure coming from a Java background. I have written a simple implementation of Conway's game of life in both Clojure and Java, trying to keep the overall structure of the code as ...
2
votes
0answers
96 views

An ISeq implementing Priority Queue

This is a follow up to my last review request. I made three major changes: I had it fully implement ISeq and IPersistentStack, ...
2
votes
0answers
73 views

A Priority Queue implemented using a Linked List

I'm going to write a Huffman Coding implementation, and decided to write from scratch a priority queue to help out. I've never written a priority queue before, in any language, so this was interesting....
2
votes
0answers
241 views

Simple client/server library

I'm writing a Tamagotchi clone, and decided to try making an online version. Since I don't do a lot of networking projects, I decided to try and go off on a tangent and screw around with sockets and ...
2
votes
0answers
189 views

Functional way to handle JMSConnection open and close with Clojure

I wrote this code to automatically open and close my JMSConnection's in Clojure: ...
2
votes
0answers
105 views

Code “beautifier” in Clojure

I've recently made a plugin that "beautifies" code. What it does is lump all the semicolons and curly braces to one side of the program, thus making the code "whitespace-sensitive", and therefore "...
2
votes
0answers
140 views

Function to log arguments and return value of any function in Clojure

I have implemented a function, which logs the inputs and outputs of any function, indenting the log based on the depth of the call stack: ...
2
votes
0answers
207 views

Selectively flatten JSON structure

Today I spent quite some time on providing a solution for a Stack Overflow answer. It looked quite easy to me, but my solution is complex. The question can be found here and this is my answer. If I ...
2
votes
0answers
98 views

Handling async in Clojure

I've defined myself a function for caching requests and their responses in a browser environment; I'm using ClojureScript. ...
2
votes
0answers
569 views

“Partial solution” on Code Eval for Clojure FizzBuzz

I'm just getting started on the site CodeEval, and I submitted my first solution today. What I don't understand is why it's marking my (working) answer as only a "partial solution". The site doesn't ...
2
votes
0answers
309 views

A* search algorithm in Clojure

Cost of nodes are represented by a matrix (called world), heuristic cost estimate/g score/f score are all represented in matrices. The world and its size are ...
2
votes
0answers
599 views

Prime numbers generator in Clojure

Any suggestions on improvement are welcome. ...
2
votes
0answers
101 views

Re-implementation of Caolan McMahon's parallel and map functions

I have wrote my first reasonably complete piece of ClojureScript code and would like feedback. It is basically a re-implementation of Caolan McMahon's parallel and map functions from async in ...
1
vote
0answers
32 views

Clojure test for Git operations

Is this code a good test for a testable Clojure code? ...
1
vote
0answers
65 views

Naïve Prime Factorization in Clojure

I saw a question about prime factorization on Stack Overflow and realized I had never attempted it before. This was what I ended up with after some playing around and tweaking. I'd like improvements ...
1
vote
0answers
69 views

Number Stringifier in Clojure

As an exercise, I decided to write a program that spells out numbers. For example: (stringify-int 12345) => "twelve thousand three hundred forty-five" It ...
1
vote
0answers
74 views

Clojure macro to gather functions in a namespace into a map

I'm learning Clojure via a pet project. The project would consist of several workers that would be called from other functions. Each worker is defined in their own namespace as a set of functions (...
1
vote
0answers
27 views

Cleanly preventing flashing an element from corrupting future flashes

For a Seesaw (Swing) app I'm writing, I need to be able to flash a component for a certain duration. Here's the basic function I came up with that accomplishes this: ...
1
vote
0answers
69 views

Generate a random, nested map

To answer a question on Stack Overflow, I needed to generate a large, nested map that I could postwalk over to do some testing. After a couple stabs, this is what ...
1
vote
0answers
86 views

Performance concerns when solving sliding-tile-puzzle via A* algorithm

I have implemented n-puzzle solving in Clojure using A-star algorithm. The following code, when used like this: (solve [0 1 2 3 4 0 6 7 5 8] 3) would return ...
1
vote
0answers
579 views

Infix to RPN converter using the Shunting-Yard Algorithm

I need to be able to parse simple equations in an app I'm writing, and decided to try writing my own parser. I ended up using the Shunting-Yard Algorithm to convert from infix notation to RPN as the ...
1
vote
0answers
84 views

Answering Master Clojure for the Brave and True - concurrency exercises

I recently answered the two exercises at the end of this chapter of Clojure for the Brave and True (see the end of the page). First exercise: count words in random quotes (in parallel) This is my ...
1
vote
0answers
181 views

Clojure core.async to handle communication with rabbitmq

I'm learning how to use rabbitmq in the course of writing a webapp in Clojure that will need to call out to Python for occasional machine learning. On the Clojure side, the main library is Langohr, ...
1
vote
0answers
33 views

Map-range supporting different precisions

I'm writing a Mandelbrot Set implementation, and to map the "Mandelbrot" coordinates to screen coordinates, I'm using Quil's map-range function. Essentially, it ...
1
vote
0answers
227 views

Transforming between hiccup and enlive/clojure.xml data structures using spec

I've made functions that transform hiccup <-> enlive Example: [:div [:p {:class "foo"} "bar"]] <-> ...
1
vote
0answers
423 views

Pattern match on type in Clojure spec conformer

I am using Clojure spec to conform (coerce) a 1 or 2 value of a number type or string into a 1, 2 or :clojure.spec/invalid. ...
1
vote
0answers
173 views

Understanding lazy sequence in Clojure

In order to understand how the lazy sequences work in Clojure, I decided to implement the quick-sort example from the "The Joy of Clojure, Second Edition" book simulating lazy sequences in Java. Of ...