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

7
votes
1answer
45 views

“Curious Numbers” (HackerRank PE 34)

I was inspired by a certain recent question to try my hand at this challenge: Project Euler #34: Digit factorials \$19!\$ is a curious number, as \$1!+9!=1+362880=362881\$ is divisible by ...
5
votes
2answers
80 views

Document term matrix in Clojure

This is my very first foray into Clojure (I'm normally a Python-pushing data-type). I'm trying to create a simple term-document matrix as a vector of vectors, out of a vector of strings. For those ...
5
votes
0answers
36 views

Tracking the bounding box of a map

Context I have a bunch of data points that look roughly like this: ...
4
votes
3answers
94 views

Adding augmented maps to a vector based on regex text grabbing

This is my latest brain child for clojure, could it be done with less code, cleaner, or in a more re applicable way? I am at a pretty early stage in my clojure learning so an in depth explanation of ...
2
votes
1answer
48 views

Integer square root

This essentially performs the same function as exact-integer-sqrt in math.numeric-tower. ...
0
votes
0answers
42 views

Printing binary trees

After writing this answer, I was inspired to try to design a more elegant solution to the problem of printing binary trees. And what better tool with which to seek elegance than Clojure? The ...
0
votes
0answers
37 views

Performance Optimized Project Euler Problem 14 in Clojure

Here is the problem: The following iterative sequence is defined for the set of positive integers: n → n/2 (n is even) n → 3n + 1 (n is odd) Using the rule above and starting ...
0
votes
1answer
22 views

Read Twitter direct messages and check messages for links

I'm learning Clojure and I'm doing a little thing that reads direct messages from Twitter using twitter-api wrapper. The code doing that is below. ...
2
votes
1answer
41 views

Reversing all nested sequences

I'm writing a function that returns all (nested) sequences reversed: ...
2
votes
0answers
66 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
32 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
45 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 ...
5
votes
1answer
167 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
40 views

Add an entry to every element in a nested data structure

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

Printing a nested data structure in Clojure

I wrote the following code which transforms a nested data structure ...
3
votes
2answers
147 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
49 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
52 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
109 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
67 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: ...
1
vote
3answers
378 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
53 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
66 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: ...
6
votes
2answers
111 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
62 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
88 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
314 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. ...
1
vote
0answers
152 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
40 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
280 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
80 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
124 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
114 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
80 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
64 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
53 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
38 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
96 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
93 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
121 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
168 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
275 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
41 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
164 views

Prime numbers generator in Clojure

Any suggestions on improvement are welcome. ...