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

1
vote
0answers
29 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 ...
1
vote
0answers
26 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 ...
2
votes
1answer
39 views

RLE-like string compression in clojure

There have been already many similar questions to this one (e.g. this and this, just to point two), but I did not find any for clojure. The goal is to compress a string in a RLE-like way: i.e. each ...
6
votes
1answer
138 views

Shuffle a deck of cards, using the overhand shuffle method

I've started learning Clojure, after many years of Java. As one of a series of exercises, I'm writing a simple card game, and the overhand-shuffle function is shown ...
2
votes
1answer
37 views

Add an entry to every element in a nested data structure

I currently use a data structure like this: ...
6
votes
1answer
34 views

Printing a nested data structure in Clojure

I wrote the following code which transforms a nested data structure ...
3
votes
2answers
139 views

Djikstra's algorithm in Clojure

I'm learning Clojure and I'm interested in areas that could be more idiomatic. The main function is below. If you're interested in the whole lib, check out this. The function operates on a ...
6
votes
1answer
47 views

Creating and displaying a checkers board

I am learning clojure this week end and just starting to develop a simple checkers engine. I currently coded some basic functions to create the board and display it. I would love to get some feedback ...
4
votes
1answer
43 views

Visualizing Brainf_ck interpreter in ClojureScript

I have written a working Brainfuck interpreter using ClojureScript, reagent, core.async and dommy. I am not very satisfied with the code, however, in particular the central part of the code - the ...
9
votes
2answers
101 views

Number factorization in clojure

I'm just a Clojure noob (started learning yesterday). Here is my helloworld program. It factorizes number into primes. Do you have any comments? How could I make this code cleaner and shorter? Maybe ...
4
votes
1answer
60 views

Sending mail using nodemailer in Clojure

I'm very new to Clojure/ClojureScript and have a question regarding a "proper" way to express something. This code sends a mail using nodemailer on nodejs: ...
4
votes
2answers
75 views

Squaring a tree in Clojure

I am working on Problem 2.30 from Structure and Interpretation of Computer Programs. I book is in scheme, but I am doing the exercises in Clojure. The problem is to write code that takes a tree of ...
1
vote
1answer
55 views

Merge sort in Clojure

I made my own version of merge sort: ...
2
votes
3answers
369 views

Sum of digits in Clojure

I wrote a simple program to sum the digits of a number in Clojure for learning purpose. Not very complex (I hope) so not adding any explanation. I am a beginner in Clojure so please don't mind ...
0
votes
0answers
46 views

RabbitMQ RPC client

I'm familiarising myself with RabbitMQ and Clojure, so I looked at the Get Started guide for the former and added the client and server parts for the RPC tutorial. I already got the feedback that ...
1
vote
2answers
61 views

PMX crossover implementation in Clojure

I'm starting to learn Clojure and as an exercise I've implemented the following functions (written in Java) in Clojure: ...
5
votes
2answers
84 views

Reading lines from a file in random order

I originally wrote this as an answer to a question on Stack Overflow, but it turned out so nicely that I decided to post it here to see if I can make it even better. ...
4
votes
1answer
56 views

Clojure word count

I'm fairly new to Clojure and looking to improve my use of the proper idioms, and make my code more readable. Here's the problem: Read from standard input and produce the count of each word to ...
2
votes
1answer
87 views

Function to discard repeats, applied to numbers

Solving a 4Clojure problem, I got this answer to compress a sequence (problem 30): #(map first (partition-by identity %)) What would be the best approach to have ...
2
votes
1answer
311 views

Program for printing all numbers that user inputs till 42 in Clojure

As the name suggests it is a very simple program to print numbers to screen till user inputs 42. ...
0
votes
0answers
87 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 ...
3
votes
1answer
34 views

Create a sorted-map of coordinates

I wrote a little function to create a sorted-map with vectors of coordinates as keys and an empty map as a default value: ...
15
votes
1answer
271 views

Clojure Minesweeper from scratch

In order to exercise and learn Clojure, I decided to write a simple Minesweeper game from scratch. I'd consider myself as a Clojure novice and would be thankful if somebody could do a review or give ...
1
vote
1answer
28 views

Capping values in a map while keeping one fixed

I'm working with some Clojurescript code that reacts to user input over three sliders. These sliders get stored in a map, and I need to make sure that the sum of all is <= a ...
3
votes
1answer
76 views

Converting Between Clojure Maps and Lists

In an attempt to learn better functional programing I've attempted to convert some Python to idiomatic Clojure, but I'm not sure how well I did with parts of it. One thing I found myself doing a lot ...
6
votes
1answer
103 views

Dining Philosophers Problem in Clojure

I have implemented the Dining Philosophers Problem in Clojure with refs, trying to emphasize readability. Please point out if parts of it are inefficient, not idiomatic, or improvable in any way. Full ...
6
votes
3answers
106 views

Number of Chocolates to Gluttonize in Clojure

I’ve been dabbling in Clojure by solving programming puzzles. This particular puzzle is from HackerRank, with the objective of figuring out how much chocolate one could eat given three parameters: ...
4
votes
1answer
75 views

Number guessing game in Clojure

I have recently started learning Clojure, and decided to write a number-guessing-game as an exercise. The game works as follows: User enters minimum and maximum values Computer generates a number ...
5
votes
1answer
63 views

Brainfuck interpreter in Clojure

I'm currently learning Clojure to try to get a good understanding of functionnal programming, so I wrote this brainfuck interpreter that takes a filename on the command line. I tried to make it as ...
1
vote
2answers
52 views

Simple Grid Builder for Future Maze Applications

I'm new to Clojure and decided to read the book, "Mazes for Programmers". My first task, without reading any of the book, was to think of how I would create a maze. This is my first result and I'd ...
4
votes
0answers
37 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 ...
2
votes
2answers
33 views

Incremental accumulator by subvectoring

The purpose of the following code is to, given a vector, compute the two accumulators: 1. head-till-nth element, 2. (n+1)th element-till-last (where n, and this is the catch, iterates from 1 till ...
2
votes
2answers
90 views

Structure of parser in Clojure

I'm working on my first Clojure project, which is a parser. Since it's my first project I'm unsure of many aspects, from my general approach to solving this problem to the small implementation ...
1
vote
0answers
91 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 ...
3
votes
1answer
69 views

Remove “lines” from a 2D vec

I have some code here that I am very unhappy with. The task I am trying to accomplish is this. Given a 2d vec like this: [[0 2 0] [1 3 5] [3 3 0]] which can ...
5
votes
1answer
68 views

Designing a circuit of gates in Clojure and doing forward and backpropagation

I am reading Hacker's guide to Neural Networks. Since I am also learning Clojure, I tried to implement them in Clojure. I would like the feedback about what could be more idiomatic and better in the ...
1
vote
1answer
112 views

Managing state in Clojure

Where should you store state and how should it be managed in a ClojureScript application? Take the following code for example - it's a "game" where you travel either down or left. ...
5
votes
1answer
160 views

Starting a Clojure Chess Engine

In my journey to learn Clojure I recently decided that I would like to write a chess engine, which is kind of funny because I don't really know chess either. ;-) My goals are to learn Clojure and ...
2
votes
1answer
247 views

Simple, functional URL parsing library in Clojure

I recently wrote some code to handle parsing of URLs, even if those URLs might not be one hundred percent perfectly well-formed. (This constraint made using Java's ...
0
votes
0answers
39 views

Sieve of Eratosthenes in Clojure

I am mainly interested in how to make the sieve lazy so that it will receive something like (iterate inc 2) and generate an infinite sequence of primes, but any ...
2
votes
0answers
148 views

Prime numbers generator in Clojure

Any suggestions on improvement are welcome. ...
0
votes
1answer
67 views

Multitenant Cassandra Query in Clojure

The following code handles querying for user data in a multitenant Cassandra database. Each tenant has their own keyspace and within that keyspace data about each tenants users is stored. This code ...
4
votes
0answers
39 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 ...
1
vote
1answer
86 views

Read Space Delimited Text File to Standardized Data Type

From the README.md Introduction: The purpose of data-in is to read all the lines from a text file and return the file's contents as a Clojure value in a ...
11
votes
1answer
87 views

A port of the 1971 StarTrek game to Clojure

I ported the Star Trek 1971 game to Clojure to help me learn more about the language and functional programming in general. You can see the entire game on Github. The game plays (you can start it with ...
1
vote
1answer
34 views

Getting data from different services

I have a piece of code that tries to get some data from a different services, falling back to the next one if previous fails. The code look a little bit ugly, though. Any suggestions on how to ...
6
votes
2answers
161 views

Water pouring challenge

I'm trying to write code to solve water pouring problem in Clojure. The following code is strongly influenced by Martin Odersky's solution lectured in his coursera course, Functional Programming ...
4
votes
1answer
58 views

Using atom to reference state in Clojure

I am trying to implement a 2D fighting game in Clojure both for fun and learning. Since the characters in a fighter game are essentially state machines, I constructed the following code: ...
2
votes
1answer
63 views

Encrypting messages using the XOR operation

recently I've started to learn Clojure. I came up with an easy programming problem, described by this C code: ...
-2
votes
1answer
132 views

Clojure koans 14 - converting a map to a string

The koan is at the end of this snippet. It requires you to write a function to convert a map to a string, and then prepend a full name to it. The following solution works fine. I am just wondering if ...