Questions tagged [clojure]

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 constructs.

Filter by
Sorted by
Tagged with
2
votes
0answers
31 views

Brainfuck NASM compiler in Clojure

I've made a simple brainfuck compiler, I feel like my code is unreadable and messy, how can I improve it? src/core.clj ...
3
votes
1answer
143 views

Constructing a packet header

I am currently working on writing a library for use with LIFX light bulbs over their UDP API. I have written the code for creating the packet headers, but I'm unsure whether it is the most idiomatic ...
6
votes
1answer
120 views

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

I am an experienced self-taught professional Python programmer working my way through the book Classic Computer Science Problems in Python to try to catch myself up on some of the things I missed by ...
1
vote
1answer
53 views

Check balanced brackets

Yes, I know we have a lot of these. I'm new to Clojure, but not to lisps. After the recent (javascript?) parentheses-balancing Q, I decided to do an implementation in Clojure for practice with the ...
2
votes
1answer
47 views

Filtering vector of maps based on a blacklist

Given a vector of maps: (def my-list [{:a 1 :b 2 :c 3} {:a 1 :b 5 :c 6} {:a 7 :b 8 :c 12} {:a 10 :b 11 :c 12}]) and a blacklist: ...
3
votes
1answer
41 views

Count Words in Quotes Fetched from Website

I have solved the following exercise and would like to get some feedback on my implementation. Create a function that uses futures to parallelize the task of downloading random quotes from https://...
2
votes
1answer
37 views

A program that expands a list of maps and chooses a random element

This is the essence of chapter 3 of "Clojure for the Brave and True". This program is about completing the list asym-hobbit-body-parts by adding a given number of ...
3
votes
1answer
37 views

Get list of new questions from Stack Overflow

I would like to write a little pet project using Clojure to study it, something like Stack Overflow client. Here is a my first code to get list of new questions from site. I am in the very beginning ...
1
vote
0answers
31 views

Clojure test for Git operations

Is this code a good test for a testable Clojure code? ...
1
vote
2answers
103 views

Combined looping and recursion when implementing Quicksort, using proper Clojure style

In "The Joy of Clojure", 2nd edition, code for quicksort is introduced on page 133 that I found hard to digest. I have rewritten it to make it clearer (at least to myself). Here is the original: <...
2
votes
1answer
45 views

Table of employee with end of mission visual clue

to learn Reagent, re-frame and spec I made a little personal project. Description: Given a ...
4
votes
1answer
50 views

Langton's ant in Clojurescript

The weekly coding challenge in Eric Normand's newsletter this week involves implementing Langton's ant. I wanted something on my screen so I put together a simple re-frame app. The core functions ...
4
votes
2answers
84 views

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

A program that I work on constantly updates and modifies program state containing an arbitrarily deep and wide tree. The data looks something like this. ...
3
votes
1answer
63 views

n-puzzle in Clojurescript

I'm in the process of creating a n-puzzle solver in Clojurescript. I have the basic model up and running and can move tiles on the screen. I plan to implement A* or such an algorithm to solve a given ...
2
votes
1answer
33 views

Picking a random point along the edge of an area

I'm writing a Diffusion-limited aggregation simulation, and need to pick a random point along the edge of an area defined by a dimension pair of [width, height]. ...
4
votes
2answers
173 views

Parsing infix expressions in Clojure

I'm trying to teach myself Clojure by reading the Brave Clojure book online, and at the end of Chapter 7 there is an exercise to parse a mathematical expression written as a list in infix notation to ...
2
votes
1answer
29 views

Using deftype to create a wrapper class for byte arrays

I want to create a wrapper class for byte arrays so that I can use them as keys in fastutil's Object2LongAVLTreeMap. I have ...
3
votes
0answers
149 views

Forest Fire Cellular Automata

I stumbled on the idea of a Forest Fire simulating cellular automata, and decided to try making a version using a full Seesaw UI (a Clojure wrapper over Java's Swing). A short sample of it running is ...
3
votes
2answers
67 views

What does the Bob say? (clojure version)

I'm doing the exercices from clojureacademy. Here are the instructions for this one. Bob is a lackadaisical teenager. In conversation, his responses are very limited. Returns "Whatever." if ...
4
votes
2answers
103 views

RSS feed viewer in Clojure

This semester a classmate and I visited a course on functional programming in our university. For grading, we've to submit a small project which should be written in Clojure and make use of functional ...
2
votes
2answers
136 views

Project Euler problem 86 taking a long time

I'm trying to solve problem 86 in Project Euler. After some tinkering, I managed to unroll the DP solution into a loop. But still the solution takes >150s to complete. What can I do to improve the ...
0
votes
1answer
44 views

Naïve Prime Factorization in Clojure Pt. 2

After my last review request, I decided to try and make a "tree" visualization, and thought that I could benefit from making find-prime-factors lazily produce prime ...
1
vote
1answer
57 views

Powerset of collection in Clojure

Similar to this question, here's another implementation. Assume the input is already a set. ...
1
vote
0answers
55 views

Naïve Prime Factorization in Clojure

I saw a question about prime factorization on Stack Overflow and realized I had never attempted it before. This was what I ended up with after some playing around and tweaking. I'd like improvements ...
2
votes
2answers
80 views

Project Euler #10 (sum of primes less than two million) in Clojure

I'm new to Clojure and using some Project Euler problems to familiarize myself with the language's capabilities. Problem #10 asks to find the sum of all primes less than two million. I wanted to ...
2
votes
1answer
107 views

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

Advent of Code 2018, day 2, part 2: The [two IDs you are looking for] differ by exactly one character at the same position in both strings. For example, given the following IDs: ...
0
votes
1answer
81 views

Five functions to get the digits of a number

I'm writing a simple function: given a number, it will return a sequence or a collection of the digits in the number (in the correct order). i.e ...
2
votes
2answers
104 views

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

First of all, project Euler has been a great help for me to learn Clojure. I tried for months trying to get web projects going but ended up frustrated with and struggling with tooling and libraries ...
0
votes
2answers
103 views

Project Euler 23 implementation

This code to solve Problem 23 in Project Euler gives the correct answer. But, running the last expression takes around 40 seconds. I welcome advice on how to improve performance here. ...
1
vote
0answers
60 views

Number Stringifier in Clojure

As an exercise, I decided to write a program that spells out numbers. For example: (stringify-int 12345) => "twelve thousand three hundred forty-five" It ...
1
vote
2answers
74 views

Classic “100 doors” simulation in Clojure

I read this question about the "100 Doors" puzzle, and thought that it would make for a good quick exercise. I ended up with two implementations. The first is more straightforward and uses a vector ...
1
vote
0answers
67 views

Clojure macro to gather functions in a namespace into a map

I'm learning Clojure via a pet project. The project would consist of several workers that would be called from other functions. Each worker is defined in their own namespace as a set of functions (...
1
vote
2answers
42 views

Recamán Sequence (A005132)

I'm going to screw around with visualizing Recamán's Sequence, but want to have a good sequence generator to generate the sequence before I start. I want to use a lazy generator for my actual ...
4
votes
1answer
183 views

A* in Clojure - trickier than I expected

While working through some coding puzzles to brush up on Clojure, I encountered the need to use A* on some search problems. I tried to implement it from first principles/memory and that didn't go ...
7
votes
1answer
155 views

Avoid incoming meteors

I'm visiting a functional programming course at my university which has a small project for examination. The language we are using is clojure and the contents of the lecture have mostly been about it'...
1
vote
0answers
26 views

Cleanly preventing flashing an element from corrupting future flashes

For a Seesaw (Swing) app I'm writing, I need to be able to flash a component for a certain duration. Here's the basic function I came up with that accomplishes this: ...
0
votes
1answer
56 views

All of Clojure's Expression Threading Macros

I was bored and in a mood to write some macros, so I decided as an exercise to try and remake each of the standard threading macros: ->, ...
3
votes
1answer
61 views

Mutative Heap's algorithm (permutations generator) in Clojure

For a side project I'm working on, I need to be able to generate permutations. Instead of relying on an existing library like math.combinatorics, I decided to write ...
2
votes
0answers
77 views

An ISeq implementing Priority Queue

This is a follow up to my last review request. I made three major changes: I had it fully implement ISeq and IPersistentStack, ...
2
votes
0answers
69 views

A Priority Queue implemented using a Linked List

I'm going to write a Huffman Coding implementation, and decided to write from scratch a priority queue to help out. I've never written a priority queue before, in any language, so this was interesting....
2
votes
1answer
149 views

Kids bank account in Clojure

I'm learning clojure. A while back I made a python bank account for my kids, teaching them to save. Have a look here. The Python one was a class and it created a table that had a little interest ...
4
votes
1answer
100 views

Implementing parser combinators in a functional manner

I am just starting on my journey of learning clojure (I have just read to the end of chapter 3 in clojure for the brave and true). So for practice, I wrote some parser combinator functions. I am quite ...
3
votes
1answer
41 views

Pascal's Triangle - Remove hack

I had a thought last night on how I could easily write a Pascal's Triangle generator basically just using partition and map. I ...
2
votes
1answer
100 views

Sorting texts by similarity in Clojure

This is my first attempt with a lisp language. I'd like your review to address the following points, already listed in order of relevance: Is my code making good use of standard library? Is my code ...
3
votes
1answer
48 views

Finding the comic ID of the last XKCD comic published

I decided to sidetrack and create a XKCD viewer. For certain functionality, I needed to be able to find the ID of the last comic published. This was my attempt. I'm using Enlive here to parse the page ...
3
votes
1answer
250 views

Functional Sieve of Eratosthenes in Clojure

For some reason, this is the first time I've ever written an implementation of the Sieve of Eratosthenes. I basically just stared at the Wikipedia walkthrough of the algorithm until it made sense, ...
3
votes
1answer
99 views

Solving Knight's Travails Problem without using vector for position

I'm trying to implement a solution to the The Odin Project - Project 2: Knight’s Travails in Clojure (Functional Programming) based on the solution posted by benjdelt. I would like to know your ...
1
vote
0answers
66 views

Generate a random, nested map

To answer a question on Stack Overflow, I needed to generate a large, nested map that I could postwalk over to do some testing. After a couple stabs, this is what ...
4
votes
0answers
71 views

Macro that allows for Linear Problem notation to create Genetic Algorithm fitness functions

As a side toy project for my Genetic Algorithm, I decided to try to create a macro that lets you use maximize: ... subject to: ... linear problem notation to ...
3
votes
1answer
92 views

A running gene crossover function for a Genetic Algorithm

I'm writing a Genetic Algorithm, and need to write a function that crosses two gene sequences. Basically, I want it to work like this: ...

1
2 3 4 5
7