Skip to main content
17 votes
Accepted

Printing binary trees

First of all, in my opinion, both the algorithm is nice and interesting, and the code is really well-written, broken down into easily understandable functions! Well done! The only addition that I can ...
Attilio's user avatar
  • 1,645
7 votes
Accepted

Generate a deck of cards in Clojure / Clojurescript

There are a few minor improvements you can make here that lead to a fairly elegant implementation. First, using flatten is rarely a good idea, because rather than ...
Sam Estep's user avatar
  • 1,767
5 votes

Haversine Formula in Clojure

Naming and interface Please avoid mixing English (calculate-distance) with Portuguese (raio). The code should be in English; ...
200_success's user avatar
5 votes
Accepted

Implementing parser combinators in a functional manner

I'm going to admit right off the bat here that I've never written a parser using combinator functions before. I have quite a bit of experience with Clojure though, so I'll be primarily focusing on ...
Carcigenicate's user avatar
4 votes
Accepted

Short Clojure digit extraction

I'd simplify as follows: (defn get-digit [x k] (Character/digit (.codePointAt x k) 10)) codePointAt is a method of Java's <...
Thumbnail's user avatar
  • 1,634
4 votes
Accepted

Filtering a data structure using regex predicates

First up, notice that you're creating 3 leted names by using exactly the same expression but replacing one key lookup function. This is a prime candidate for ...
Magos's user avatar
  • 226
4 votes
Accepted

Musical graph algorithm, with an inlined lookup helper function

... I would like to understand how to properly get the most out of low level operations. ... Is this the correct way? ... Up to a point. There's little or nothing wrong with your ...
Thumbnail's user avatar
  • 1,634
4 votes
Accepted

Linked list implementation in Clojure

What do you think about the chosen data structure (nested dictionaries)? Would there be a way to implement this in Clojure, in a more efficient way? Conceptually it works. I wouldn't use plain maps ...
Carcigenicate's user avatar
4 votes
Accepted

Sorting texts by similarity in Clojure

First, the most serious problem with your code: Never, ever, ever use def inside of defn, unless you really know what you're ...
Carcigenicate's user avatar
4 votes
Accepted

Avoid incoming meteors

For code written by students new to the language, this is quite good. You haven't made any of the major mistakes that most newbies to the language make, like abuse of ...
Carcigenicate's user avatar
4 votes
Accepted

A* in Clojure - trickier than I expected

I'm not going to be able to do a very thorough review. The code doesn't have anything outright wrong with it, and I'll admit, I've never been able to implement a decent A* implementation. It's just ...
Carcigenicate's user avatar
4 votes

Clojure Prime Numbers from 1 to 1000

Note: It has been a long time since I actively played with Clojure, so I will mostly refrain from writing and/or reviewing any actual code in my answer and will only provide a high-level review. ...
Jörg W Mittag's user avatar
3 votes
Accepted

Get RSS feeds and store them into database

When using defn, the docstring goes before the arguments list, not after. In order to prevent environment coupling, functions that use a ...
Valentin Waeselynck's user avatar
3 votes
Accepted

Lazy sub sequence

One way to improve: (defn lsubseq [coll left-index right-index] (take (- right-index left-index) (drop left-index coll))) There is also a built-in function - ...
rmcv's user avatar
  • 166
3 votes
Accepted

Shuffling many collections by folding over a numeric range

If you want to transform a value v by applying a function f n times, it may be clearer to ...
Valentin Waeselynck's user avatar
3 votes
Accepted

Multiple files data processing in Clojure

Don't forget about for Consider using for instead of map in places where you use an ...
Nathan Davis's user avatar
3 votes

Code Chef RAINBOW Palindrome

(defn palindrome? [items] "Efficient algorithm: loops through only (array-size/2)" ... (not= (nth items i) (nth items j)) ...
BenC's user avatar
  • 2,738
3 votes

Program follows sequence of instructions to arrive at destination

Take a look at Bruce Hauman's answer to the question: https://github.com/bhauman/advent-of-clojure-2016/blob/master/src/advent_of_clojure_2016/day1.clj One thing that was an eye-opener to me is how ...
Chris Murphy's user avatar
3 votes
Accepted

Kids bank account in Clojure

This isn't bad code. The worst thing I see is a lot of your code is operating via side effects. You're either directly reading from file with take-csv, or carrying ...
Carcigenicate's user avatar
3 votes
Accepted

Project Euler #49: Find 12-digit number concatenating a three terms sequence

There's a few things that can be improved here: First, I'm not sure if you neglected it here or if you actually aren't using it, but every file should start with a call to ...
Carcigenicate's user avatar
3 votes
Accepted

Program finds the first almost matching string in a list - Advent Of Code 2018 Day 2 Part 2

There isn't a whole lot of code here, so I'll just point out what I see top-to-bottom. I'll note though that I'm exceedingly tired and don't fully understand what the problem you're solving is, so I'...
Carcigenicate's user avatar
3 votes
Accepted

Extract indices of visible nodes in a tree where only some nodes are expanded

You are right to want to avoid creating the nested structure to begin with. I imagine you read my answer in the question you linked (the second one). As there, here the solution is to use ...
amalloy's user avatar
  • 585
3 votes

Langton's ant in Clojurescript

I don't have any performance related suggestions unfortunately. I do have a couple cleanup suggestions though. The bounds checking function can be cleaned up a bit by making use of "comparison ...
Carcigenicate's user avatar
3 votes
Accepted

Count Words in Quotes Fetched from Website

For quote-word-count, there's a few things to note. I think this is a good use of ->>. Personally, I would have started ...
Carcigenicate's user avatar
3 votes

Check balanced brackets

I'd never thought of using reduce for this. Neat! However, you can simplify mk-balanced? a little. ...
Thumbnail's user avatar
  • 1,634
3 votes
Accepted

Clojure depth first search maze problem from Classic CS Problems in Python Book

Initial comments for only the dfs function: Variable names start makes sense for the initial point. ...
user2609980's user avatar
3 votes
Accepted

Prime factors kata solution in Clojure

There's a few notable things here: You're prepending to a list, then reversing the result at the end. It would be better to just start with a vector ([]). ...
Carcigenicate's user avatar
3 votes

A Clojure program to classify files based on their filename

fn, defn and let have implicit do, so you can remove it ...
Martin Půda's user avatar
2 votes
Accepted

2048 game implementation in Clojure

core.clj (def x 1) (def y 1) Use more descriptive names. These seem to be used as the origin for rendering the game, so ...
Nathan Davis's user avatar
2 votes
Accepted

A Simple Async Task in Clojure

Commenting on this section: ...
Valentin Waeselynck's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible