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

5
votes
4answers
359 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
363 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
115 views

Idiomatic text munging in Clojure

In getting accustomed to Clojure syntax, I wrote the following stutter function: ...
2
votes
1answer
266 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
141 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 / ...
6
votes
1answer
714 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
348 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
207 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
111 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? ...
3
votes
1answer
246 views

Implementation of Python's re.split in Clojure (with capturing parentheses)

If you use capturing parenthesis in the regular expression pattern in Python's re.split() function, it will include the matching groups in the result (Python's ...
6
votes
2answers
214 views

Expanding a map, style guidance

I have a map that I want to 'expand' into an infinite sequence in the following manner: ...
5
votes
1answer
782 views

Higher-order FizzBuzz in Clojure

Help me make it better. Requirement: support arbitrary number of factors, not just 3 & 5. ...
4
votes
3answers
955 views

Find the common characters between two strings without using set operations

Below are two implementations of the problem "find the characters in common between two strings" - in Clojure without using collections / set operations. Are these approaches sufficiently idiomatic ...
7
votes
2answers
442 views

Powerset in Clojure

I think I have correctly implemented Powerset in Clojure. ...
7
votes
1answer
492 views

Clojure TicTacToe (Logic, no Gui)

I whipped this up last night and was wondering if anyone had any thoughts/comments on it; for example, on: Code organisation Coding style Other improvements Semantic errors All feedback is ...
8
votes
1answer
226 views

Bayesian approximation method for online ranking

I've implementing the this algorithm in Java, Scala, and Clojure to show my teammates. I know the code works as expected. What I'm looking for is tips on good Clojure style. ...
2
votes
1answer
232 views

idiomatic clojure (map from sequence generation)

It's my first clojure script (simple word translator based on wikipedia), and I guess there are things which could be simplified / done more idiomatic way. Specifically, I wonder if get-translations ...
4
votes
3answers
362 views

Clojure MapReduce Reducer

This program forms the reducer of a Hadoop MapReduce job. It reads data in from stdin that is tab delimited. foo 1 foo 1 bar 1 and outputs ...
5
votes
1answer
410 views

Enumerate k-combinations in Clojure (P26 from 99 problems)

I've been playing with Clojure for the last few evenings, going through the well known 99 problems (I'm using a set adapted for Scala). Problem 26 calls for a function that, given a set S and a no. ...
8
votes
2answers
839 views

Review my implementation of Viterbi in Clojure?

I would be grateful for suggestions that I use to turn this code into more idiomatic clojure code. I've probably done some pretty horrendous things here, but I'm throwing it out for people to give me ...
7
votes
1answer
406 views

Unix sort in Clojure

I am implementing Unix sort in Clojure. This is my first program, and I would like some feedback regarding any non-idiomatic, harmful code and any other best practices I can include in future ...
2
votes
1answer
174 views

More concise way to write this clojure code adapted from map-invert?

I wanted to do the following: Count the frequencies of words in a text (over 5 letters) Invert the map of words to frequencies, but group together words that have the same frequency in the ...
4
votes
1answer
137 views

Improve this Clojure code to construct a tail cmd?

I wrote this without much thought: ...
2
votes
1answer
219 views

Three (do)s in a Clojure method

I'm new to Clojure. How can I make this more idiomatic Clojure code? Among other things, there are three (do) blocks and I don't think using (def) as many times as I do is a recommended idea. ...
4
votes
1answer
329 views

A crude clojure progress reporting function

Please review this newbie's clojure code (mine). The purpose of this function is to report processing progress to the terminal. It loops through an array of maps that contain two properties: ...
4
votes
1answer
219 views

Lazy look and say sequence

I have been solving a set of online Clojure problems. One of them involves the look and say sequence. ...
1
vote
3answers
112 views

From enumerator to map

I have an mail object that returns its headers as an Enumerator of Header objects, which have two methods, getName and getValue. I need to convert that to a nice Clojure map so I wrote this short ...
6
votes
3answers
342 views

Finding the sum of the digits appearing in the leaves via in-order traversal

The following text is an in-order traversal of a binary tree with 1023 nodes. What is the sum of the digits appearing in the leaves? How can I improve this Clojure code? It looks strange to me ...
3
votes
2answers
319 views

Searching for repeated characters in a sequence of characters

The following code solves this problem: The 3072 characters below contain a sequence of 5 characters which is repeated. However, there is a twist: one of the sequences has a typo. To be ...
6
votes
4answers
926 views

Clojure — partitioning strings into substrings of fixed length

Hey all, I've got a clojure function here that's meant to parse a string of form "DDXXXYYY" where DD is meant to be discarded, and XXX and YYY are string ...
10
votes
3answers
422 views

Reservoir Sampling in Clojure

I am learning clojure and decided to start out by trying to write a solution to a fairly simple algorithm, reservoir sampling. As I stated, I am learning clojure specifically and problem solving in a ...
15
votes
3answers
1k views

Project Euler Problem 2 in Clojure

I am in the process of learning Clojure. I am fairly new to functional programming and would like to know if my code smells or if there are any performance implications with my approach. ...