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

2
votes
1answer
56 views

Adding/removing map values: unsymmetric implementation

I am learning Clojure by implementing a simplistic resource reservation system. At its core are the two functions for placing/canceling reservations for a given resource: ...
3
votes
1answer
79 views

Print matrix in spiral order

I have a task formulated like this Please print a matrix in spiral order, clockwise from outer rings to inner rings. I decided to implement it in Clojure. ...
1
vote
1answer
43 views

Wrapping a character code for a Caesar Cipher

I'm writing a Caesar Cipher. To deal with characters being shifted to outside of the "normal" printable ASCII range ([32 126]), I'm having them "wrapped" to the max/...
1
vote
1answer
57 views

Exercism: clean and format a phone number in Clojure

Problem statement Phone Number Write a program that cleans up user-entered phone numbers so that they can be sent SMS messages. The rules are as follows: If the phone number is ...
1
vote
2answers
39 views

Formatting a date in ClojureScript

I want to convert strings with the iso date format (2015-08-02) to the default format of our app (2 Aug 2015) in ClojureScript. ...
0
votes
1answer
29 views

Factoring out a “get-change-set” pattern with Clojure's Records

I'm remaking an old program of mine in Clojure. It involves "Beings" (generic entities capable of attacking and breeding) let loose in a confined space. I've noticed a pattern of taking a record, ...
4
votes
1answer
65 views

Building blocks of Life

I'm learning Clojure, and decided to write a Conway's Game of Life clone as my starting project. I ended up dicking around for a bit before diving in, and came up with a few functions that I'd like ...
2
votes
1answer
49 views

Spiral a matrix of size NxN filled with integers from 1 up to and including n^2

I have written a solution in Clojure for the following question: When starting from the number 1 and adding three numbers on each row a 3x3 matrix is formed as follows: ...
2
votes
1answer
58 views

Clojure counter

I'm learning clojure ref types and was trying to make a robust counter generating function. Is there any error or improvement on the code? is there a simpler way? (I want the function to be thread-...
3
votes
0answers
117 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 ...
5
votes
1answer
61 views

Selecting HTML nodes

I'm new to Clojure, and I'm writing some code that processes HTML. I'm parsing the HTML using clj-tagsoup and then trying to pull out the relevant bits with this function: ...
4
votes
2answers
55 views

Number of ways to make change for an amount

Task Write a program that, given the amount to make change for and a list of coins prints out how many different ways you can make change from the coins to STDOUT. My approach The number to make ...
6
votes
1answer
47 views

Matrix Diagonal Difference

Problem Given a square matrix of size N×N, calculate the absolute difference between the sums of its diagonals. Input Format The first line contains a single ...
5
votes
1answer
113 views

Generating XKCD passwords

Obviously, everyone should use a password manager to generate and store long unique random strings of characters for the vast majority of their passwords. However, one still needs to memorize a master ...
3
votes
1answer
53 views

Clojure reverse multiple times

I have a piece of Clojure code that reverses a string recursively. It is working but too slow (because I got the problem from Codewars and I cannot validate it ...
3
votes
1answer
42 views

Run tasks in parallel using limited number of threads

To learn about concurrency in Clojure, I wrote a function that accomplishes the following: Takes a (possibly lazy or infinite) sequence of functions representing tasks to be run asynchronously Runs ...
8
votes
1answer
100 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
95 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 ...
10
votes
0answers
100 views

Tracking the bounding box of a map

Context I have a bunch of data points that look roughly like this: ...
5
votes
3answers
110 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
62 views

Integer square root

This essentially performs the same function as exact-integer-sqrt in math.numeric-tower. ...
20
votes
0answers
301 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? Overall ...
0
votes
0answers
48 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
23 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
50 views

Reversing all nested sequences

I'm writing a function that returns all (nested) sequences reversed: ...
2
votes
0answers
80 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
42 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
51 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
255 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
47 views

Add an entry to every element in a nested data structure

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

Printing a nested data structure in Clojure

I wrote the following code which transforms a nested data structure ...
3
votes
2answers
181 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
59 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
54 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
124 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 I ...
4
votes
1answer
81 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
87 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
58 views

Merge sort in Clojure

I made my own version of merge sort: ...
1
vote
3answers
437 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
77 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 ...
2
votes
2answers
85 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: ...
7
votes
2answers
137 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
81 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
321 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
332 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
49 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
291 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
29 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
81 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 ...