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 ...
1
vote
0answers
18 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
47 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 ...
3
votes
1answer
64 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
30 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
12 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
90 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
40 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, ...
2
votes
0answers
32 views
4
votes
3answers
100 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
71 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
133 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
131 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. ...
2
votes
2answers
32 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
116 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 ...
1
vote
1answer
69 views
How do I bind a symbol in a conditional in Clojure? [closed]
In Ruby (on Rails) I would do this in a controller action to provide authentication:
...
3
votes
2answers
80 views
Clojure Tic Tac Toe solver
I am going through the 4clojure problems and I currently just solved the Tic Tac Toe analyzer:
...
5
votes
1answer
253 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 ...
8
votes
1answer
111 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
41 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
59 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
48 views
5
votes
1answer
103 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
83 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
83 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
118 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
86 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 ...
3
votes
1answer
91 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
141 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 ...
1
vote
1answer
49 views
Project Euler #20 solution in Clojure
Problem:
\$n!\$ means \$n × (n − 1) × ... × 3 × 2 × 1\$
For example, \$10! = 10 × 9 × ... × 3 × 2 × 1 = 3628800\$, and the sum of the digits in the number \$10!\$ is \$3 + 6 + 2 + 8 + 8 + 0 + ...
3
votes
3answers
111 views
More succinct / ideal solution to Project Euler #22
"Using names.txt (right click and 'Save Link/Target As...'), a 46K text file containing over five-thousand first names, begin by sorting it into alphabetical order. Then working out the alphabetical ...
5
votes
0answers
199 views
Translating CFRM algorithm from Java to Clojure and improving performance
Counterfactual Regret Minimization is an algorithm that can be used to find the Nash Equilibrium for games of incomplete information. I have tried to adapt the exercise from here to Clojure. You can ...
6
votes
2answers
133 views
Package manager in Clojure
I wrote a package manager in clojure that does 5 things:
depend a b //creates a and b (if they don't exist) and adds dependency on a
install a //installs a and its dependencies
list //prints out ...
1
vote
0answers
44 views
3
votes
2answers
51 views
Basic reverse function
I am just starting out in my Clojure journey and I wonder if anybody can point out my beginners mistakes in my function below that simply reverses a list. I know that there is already a reverse ...
5
votes
1answer
74 views
Second to last word
Grab the input file, and output the second to last word on every line.
Can I make it shorter and/or more efficient?
I'm surprised by the performance. While the runtime, +2s, is likely dominated by ...
10
votes
1answer
282 views
Is this the Clojure way to web-scrape a book cover image?
Is there a way to write this better or more Clojure way? Especially the last part with with-open and the let. Should I put the ...
1
vote
1answer
45 views
Scamble a vector, preserving the sum
My first crack at clojure... if you have time to provide input, I'd appreciate it. I'm as much interested in style as proper usage. I'm just getting started.
The task to start with an vector of N ...
4
votes
1answer
94 views
Exercism assignment for word-count in Clojure
I would appreciate some insights / comments from Clojure regulars out there about my submission here.
...
6
votes
1answer
89 views
Database Migrations
I'm starting to learn Clojure, and would like feedback on some code I wrote to manage database migrations. Any recommendations to make it more robust, efficient, idiomatic, elegant, etc... are ...
3
votes
1answer
86 views
Generating two .csv files from named parameters
I wrote Clojure code which takes named params and has to generate 2 .csv files as output.
Please review it.
...
2
votes
1answer
86 views
Filtering a dictionary by subject of definitions
I am writing a function to filter a "dictionary" by the "subject" of its definitions.
The dictionary data structure is a hash-map of this kind:
...
4
votes
2answers
119 views
Centroid of a polygon in Clojure
I am studying Clojure and functional programming. I wrote this function to compute the centroid of a polygon specified as a vector of points, e.g. ...
8
votes
1answer
905 views
Clojure Neural Network
After reading this article about Neural Networks I was inspired to write my own implementation that allows for more than one hidden layer.
I am interested in how to make this code more idiomatic - ...
5
votes
1answer
114 views
A text-templating system similar to PHP…but with Clojure
I wrote a simple text-templating/processing system which resembles PHP, except that it works with Clojure. The main goal was to provide an easy way to use Clojure PHP-style for small files.
This is a ...
10
votes
1answer
404 views
Idiomatic clojure code in a markdown parser
Some time ago I created a markdown parser in clojure and I would like to get some feedback, since I'm a clojure noob in the first place (is the code understandable?/is it idiomatic?/can some things be ...
3
votes
1answer
448 views
Idiomatic input parsing in clojure
I've been playing around with Clojure for a while now, and one of the tasks I occasionally find awkward is parsing input. For example, I took part in the facebook hacker cup recently, where part of ...
6
votes
1answer
2k views
Clojure - substring? function
Trying to write a substring function in Clojure. I am sure there is a more idiomatic way. Can anyone enlighten me?
Otherwise, here is my version. Thoughts?
...
5
votes
1answer
170 views
Hangman - my first Clojure code
This is my first attempt at Clojure! Apart from all game related issues, how is my code? Is there anything I can do to make it more idiomatic?
...
7
votes
1answer
281 views
Clojure tokenizer
Please review the following Clojure tokenizer. The goal is to study Clojure, so sometimes I re-implement functions (it will be nice to see standard functions for this). Beyond of this, code seems ...
3
votes
1answer
108 views
Clojure function greater than 10 SLOC
It has been mentioned in the Clojure Style guide to avoid functions longer than 10 SLOC but mine has more than 10 (47 to be exact).
The code is an web api implementation and follows like this:
...