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
0answers
31 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 ...
4
votes
1answer
46 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
41 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
26 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
29 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
47 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
56 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
66 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
61 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
68 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
99 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 ...
1
vote
1answer
116 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
28 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
61 views

Prime numbers generator in Clojure

Any suggestions on improvement are welcome. ...
0
votes
1answer
43 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
31 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
53 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 ...
10
votes
1answer
78 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
33 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
136 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 ...
1
vote
1answer
31 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
53 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
88 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 ...
1
vote
0answers
67 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 ...
3
votes
1answer
54 views

Getting rid of extra test during initialization of loop/recursion

I'm reluctant to ask this question. My code below works, it's intelligible, and it seems reasonably efficient. It's just that there's a trivial, nitpicky issue that's driving me crazy. The function ...
4
votes
1answer
270 views

Clojure Fibonacci

I'm a Clojure novice working through 4Clojure problems. In one problem I am supposed to create a function that takes a number and returns that number of Fibonaccis. My first thought was to create a ...
4
votes
1answer
74 views

Encapsulated state in clojure

While going through SICP and trying to implement the code in clojure, I've found that while I can get the code in chapter 3 to work, it seems to go against Clojure idioms, but I can't quite imagine ...
1
vote
1answer
55 views

Parsing HTML, XML into a hash map of products

I'm working on a simple parser that is supposed to extract hash maps representing vinyl records from web pages (online stores) and XML files. The goal is to have a parser that I can easily run with ...
3
votes
2answers
162 views

Clojure solution to HackerRank Challenge 'Restaurant' under Number Theory

My main concern is how messy the min-number-of-slices function is. I would appreciate help finding good ways to clean that up since it has a lot of nesting/scope. ...
1
vote
1answer
64 views

Determine if braces in a string are balanced in Clojure

I'm currently learning Clojure, and am working through a few exercises. The exercise that I'm working on right now is accept an arbitrary string and determine if the opening and closing parenthesis, ...
3
votes
1answer
51 views

Simple spec testing DSL

I wrote a very small little DSL for spec testing: ...
4
votes
3answers
112 views

Clojure programming exercise for calculating change

I'm learning Clojure and have written a small function to calculate change. I don't like few things about the code and would primarily like to replace recursive call with something more idiomatic. ...
2
votes
3answers
86 views

Memorable combinations for Sargent mechanical combination locks

I have a safe with a manual combination lock that I periodically change the combination to. I like to use a combination that's easy for me to remember, so I thought I'd write a quick Clojure program ...
3
votes
0answers
162 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 ...
2
votes
2answers
218 views

Computing pairwise bitwise OR in a list of bit-strings

I am trying to solve this problem using Clojure: You are given a list of \$N\$ people who are attending ACM-ICPC World Finals. Each of them are either well versed in a topic or they are not. ...
1
vote
2answers
44 views

Split every vector in a sequence into two parts: old elements that were contained in previous vectors and new elements never before seen

Am I doing it right? Is there some function in the standard library I should be using? This is my first real(ish) world Clojure program… Input ...
5
votes
2answers
127 views

Performing an algebraic regression on syntax trees

I am quite new to Clojure and would need some advice on the following genetic programming gist I wrote as my first working clj program. The aim of it is to perform an algebraic regression using ...
3
votes
2answers
106 views

Clojure Tic Tac Toe solver

I am going through the 4clojure problems and I currently just solved the Tic Tac Toe analyzer: ...
6
votes
1answer
498 views

Clojure core.async web crawler

I'm currently a beginner with clojure and I thought I'd try building a web crawler with core.async. What I have works, but I am looking for feedback on the following points: How can I avoid using ...
10
votes
1answer
179 views

Project Euler #2 - Sum of even Fibonacci numbers to 4,000,000

This particular problem has already been posted here before, but the community is ok with me to post it again, so I can have feedback on my own implementation. I tried to keep things simple, with ...
2
votes
1answer
49 views

Recreating merge-with

Just working through the questions on 4Clojure as I learn the language. This is my solution for #69. Would appreciate feedback as this one gave me a little trouble. ...
4
votes
1answer
64 views

Zeckendorf numbers the Clojure way

I'm just getting into Clojure, and I wanted to make sure I am writing code the "Clojure way". The challenge I took on is Zeckendorf numbers (fairly trivial). ...
1
vote
1answer
57 views
5
votes
1answer
138 views

Algorithm to Iterate All Possible Strings in Clojure

I'm fairly new to Clojure and I struggled a bit coming up with a nice Clojure-y solution for implementing an algorithm for one of my applications. The real issue I'm trying to solve would require a ...
4
votes
3answers
102 views

Parsing US address with Clojure

The parser below is not designed for every single US address. I am parsing through a file where each line may or may not be an address. I am more focused on speed rather than robustness. ...
2
votes
1answer
138 views

Clojure code for generating HAL JSON responses

I wanted to use hal in one of my personal Clojure projects, but unfortunately the only library I could find (halresource) was somewhat out of date when compared to the current specification. So, I ...
1
vote
1answer
130 views

Finding an entry in a Hashmap

I've been playing around with functional programming for a while now and just started learning Clojure. So the problem I'm trying to solve is the following: I have a tree-like hashmap of tasks where ...
3
votes
2answers
105 views

Clojure function composition: logging results of an action performed by a “pure” function

I'm wondering how I could compose this program better allow it to grow more functionality without constant refactoring. This is my code sample for Hacker School, so I'm less married to the results ...
2
votes
1answer
116 views

“Cookie Clicker Alpha” solution

I am trying to learn Clojure for some time. In my experience, it has been rather too easy to produce write-only code. Here is a solution to a simple problem with very little essential complexity. ...
4
votes
1answer
195 views

Project Euler Problem 14 in Clojure

I recently began learning Clojure. In order to get better acquainted with it, I've been tackling Project Euler challenges. Problem 14 is not really a difficult one. It asks for the number that ...