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 ...

learn more… | top users | synonyms

0
votes
0answers
46 views

Translating CFRM algorithm from Java to Clojure, + 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: ...
6
votes
2answers
70 views

Package manager in Clojure

I wrote a package manager in clojure that does 5 things: depend a b //creates a and b (if they don't exist) and adds dependency on a install a //installs a and its dependencies list //prints out ...
2
votes
1answer
24 views

Basic reverse function

I am just starting out in my Clojure journey and I wonder if anybody can point out my beginners mistakes in my function below that simply reverses a list. I know that there is already a reverse ...
5
votes
1answer
52 views

Second to last word

Grab the input file, and output the second to last word on every line. Can I make it shorter and/or more efficient? I'm surprised by the performance. While the runtime, +2s, is likely dominated by ...
4
votes
1answer
71 views

Is this the Clojure way?

Is there a way to write this better or more Clojure way? Especially the last part with with-open and the let. Should I put the ...
1
vote
1answer
35 views

Scamble a vector, preserving the sum

My first crack at clojure... if you have time to provide input, I'd appreciate it. I'm as much interested in style as proper usage. I'm just getting started. The task to start with an vector of N ...
4
votes
1answer
46 views

Exercism assignment for word-count in Clojure

I would appreciate some insights / comments from Clojure regulars out there about my submission here. ...
6
votes
1answer
64 views

Database Migrations

I'm starting to learn Clojure, and would like feedback on some code I wrote to manage database migrations. Any recommendations to make it more robust, efficient, idiomatic, elegant, etc... are ...
3
votes
1answer
44 views

Generating two .csv files from named parameters

I wrote Clojure code which takes named params and has to generate 2 .csv files as output. Please review it. ...
2
votes
1answer
78 views

Filtering a dictionary by subject of definitions

I am writing a function to filter a "dictionary" by the "subject" of its definitions. The dictionary data structure is a hash-map of this kind: ...
4
votes
1answer
79 views

Centroid of a polygon in Clojure

I am studying Clojure and functional programming. I wrote this function to compute the centroid of a polygon specified as a vector of points, e.g. ...
6
votes
1answer
680 views

Clojure Neural Network

After reading this article about Neural Networks I was inspired to write my own implementation that allows for more than one hidden layer. I am interested in how to make this code more idiomatic - ...
4
votes
1answer
73 views

A text-templating system similar to PHP…but with Clojure

I wrote a simple text-templating/processing system which resembles PHP, except that it works with Clojure. The main goal was to provide an easy way to use Clojure PHP-style for small files. This is a ...
9
votes
1answer
239 views

Idiomatic clojure code in a markdown parser

Some time ago I created a markdown parser in clojure and I would like to get some feedback, since I'm a clojure noob in the first place (is the code understandable?/is it idiomatic?/can some things be ...
3
votes
1answer
138 views

Idiomatic input parsing in clojure

I've been playing around with Clojure for a while now, and one of the tasks I occasionally find awkward is parsing input. For example, I took part in the facebook hacker cup recently, where part of ...
5
votes
1answer
432 views

Clojure - substring? function

Trying to write a substring function in Clojure. I am sure there is a more idiomatic way. Can anyone enlighten me? Otherwise, here is my version. Thoughts? ...
4
votes
1answer
136 views

Hangman - my first Clojure code

This is my first attempt at Clojure! Apart from all game related issues, how is my code? Is there anything I can do to make it more idiomatic? ...
6
votes
1answer
146 views

Clojure tokenizer

Please review the following Clojure tokenizer. The goal is to study Clojure, so sometimes I re-implement functions (it will be nice to see standard functions for this). Beyond of this, code seems ...
3
votes
1answer
97 views

Clojure function greater than 10 SLOC

It has been mentioned in the Clojure Style guide to avoid functions longer than 10 SLOC but mine has more than 10 (47 to be exact). The code is an web api implementation and follows like this: ...
1
vote
1answer
163 views

Clojure code for finding prime numbers

This is my Clojure code for finding prime numbers. Note: this is an advanced version which starts eliminating from i*i with step ...
1
vote
4answers
255 views

Being Lispy with Hy, a Python Lisp dialect

I think I'd like to learn Clojure eventually, but at the moment am having fun with Hy, a "dialect of lisp that's embedded in Python." ...
3
votes
0answers
177 views

API wrapper for Clojure, idiomatic style for libraries?

I wanted to wrap the jkeymaster library in a Clojure wrapper (for my own use, but perhaps also to save others some time). I'm just learning Clojure so I'm still not quite sure what "idiomatic ...
6
votes
0answers
330 views

Connect Four AI (Minimax) in Clojure

I wrote a Connect Four game including a AI in Clojure and since I'm rather new to Clojure, some review would be highly appreciated. It can include everything, coding style, simplifications, etc. But ...
0
votes
1answer
147 views

Clojure: Idiomatic use of atom and ref?

I am working out a bit of Clojure code that will take a ref to a map and increment a key value pair in the map. I think I am using ref correctly, but Im not sure about atom. Do I need to use swap! ...
2
votes
2answers
128 views

Finding first match in recursive search

I am searching a recursive solution space and would like to return the first match I find. (I am using this to solve sudoku, but I guess this would apply to any recursively defined problem or ...
3
votes
0answers
128 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
2answers
301 views
4
votes
2answers
101 views

Is there a better way to extract a single value instead of a sequence?

The following code works, but I'd like to re-write, so that a single index is returned, rather than a sequence of indexes visited. Here are the defs and function. ...
6
votes
1answer
238 views

Excessive use of let a problem in Clojure?

I have this set of functions - it works, but I'm concerned about the use of lets. ...
2
votes
0answers
91 views

Making my back-propagation clojure code more idiomatic

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; ...
1
vote
1answer
173 views

Discovering words from letters in Clojure (Letterpress Solver)

I created a Letterpress solver that will take a string of letters and return a list of valid words that can be constructer with the provided letters. Not all letters need to be used in each word. ...
3
votes
1answer
213 views

Idiomatic Clojure? Performant & functional enough?

Problem Disclaimer: This is my first clojure function & I'm still busy finishing the last chapters of "Programming Clojure". Thanks! :) I am writing a function to randomly flood-fill parts of a ...
1
vote
1answer
67 views

How can I simplify the following to avoid sequence of maps?

Given the following code, I have written a for loop that returns a key and value (0 or 1) of file names passed. 1 means present, and 0 means not present. Is there a way to construct a flat map ...
3
votes
1answer
203 views

Inverted index in Clojure - performance vs. idiomatic code

I have this code to create an inverted index from a directory of text files: ...
6
votes
0answers
174 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 ...
2
votes
1answer
93 views

Calculating pi in clojure - any suggestions

Clojure newbie here, trying to get my head around it. Obviously there are better ways of obtaining pi, but for educational purposes, how is the code below? ...
5
votes
1answer
135 views

First Go at Clojure and Functional Programming in General

Here's the code... My goal is to simulate a Pile shuffle of a vector. Here's the function.. ...
1
vote
1answer
96 views

Clojure: Find specific element in HTML tree

I am trying to find all "link" elements that link to RSS feeds in a data structure created by clj-tagsoup. I wrote the following code, which seems to work fine. But: I come from a Java background and ...
0
votes
2answers
77 views

Idiomatic letterpress cheater

Hello dear Code Reviewers, I'm playing around with Clojure and am having a lot of fun. It's quite hard to go from imperative languages to Clojure, and I need some guidance on how to make the ...
4
votes
1answer
93 views

String-splitting function

This function was hard to write as a Clojure newbie, and I don't like the result. Can you help me find a better (more readable) way to do it? ...
5
votes
4answers
355 views

How to write this small program better?

This is just a fun little exercise I had to do for a homework once (in Java rather than Clojure though). Basically, the goal is to find the number of different coin stacks you can build with the coins ...
5
votes
3answers
321 views

Critique my Clojure “Game of Life” code

I'm a Clojure n00b (but am experienced with other languages) and am learning the language as I find time - enjoying it so far, though the strange dreams and accidental use of parenthesis elsewhere ...
1
vote
2answers
110 views

Idiomatic text munging in Clojure

In getting accustomed to Clojure syntax, I wrote the following stutter function: ...
2
votes
1answer
241 views

Find largest two numbers from list using clojure

I'm trying to write a function that finds the largest two numbers from a list of positive integers in Clojure. I've toyed around with Scheme in the past, but I'm very new to Clojure. This is what I ...
2
votes
2answers
128 views

More concise and/or idiomatic max subarray in Clojure?

I've implemented the following two versions of the classic "Max Sub-Array" problem in Clojure, using the Kadane algorithm. First with loop / ...
5
votes
1answer
630 views

Depth-first search algorithm in clojure

Context As an exercise for myself (I'm learning clojure). I wanted to implement the Depth-first search algorithm. How I did it Using recursion ...
3
votes
1answer
320 views

Connect Four: Bitboard checking algorithm

I'm rather new to Clojure and so I decided to program a Connect Four for fun and learning. The code below is a Clojure implementation of this bitboard algorithm. The whole code can be found here: ...
0
votes
1answer
194 views

Calculating a factorial with parallel sub-computations using pmap, pvalues and pcalls

In an attempt to learn more about Clojure's parallel computation functions, I devised the following task: calculate a factorial in parallel using pmap, ...
3
votes
0answers
103 views

Toggle chart series in clojurescript

I'm toggling on/off series in chart and was wondering if I was doing anything crazy. Is the atom really a good idea here? ...