Skip to main content

Questions tagged [clojure]

Clojure is a general-purpose language supporting interactive development that encourages a functional programming style, and simplifies multithreaded programming.

-3 votes
2 answers
137 views

How can we handle inserts/delete cases using Map like data structures in FP?

Let's say, that we keep track of students entering the auditorium using their IDs(Key) and their check-in time(Value) in a Map. We delete the entries once they move out of the auditorium. I want to ...
Vicky's user avatar
  • 399
0 votes
1 answer
104 views

In clojure, how to structure a simple reverse file search function to make it unit testable

I have the following pair of functions used for searching upwards for a configuration file: (defn has-config? [path] contains? (set (.list path)) "my-config") (defn find-config-path [path] (cond ...
pob's user avatar
  • 109
-2 votes
1 answer
491 views

Is Clojure a wrong choice for implementing Data Structures?

I am planning to improve my knowledge of Clojure and algorithms at the same time by implementing some known data structures in Clojure (e.g. linked lists, skip lists, bloom filter, etc.). However, I ...
Attilio's user avatar
  • 487
1 vote
0 answers
87 views

How Functional Programming addresses concurrent increment/decrement operations invoked by different users? [duplicate]

Using Functional language, How can 2 different parties achieve the result of increment/decrement operations concurrently? For the below scenario, Let's say, I've 2 quantities in stock and 2 users in ...
Vicky's user avatar
  • 399
1 vote
2 answers
878 views

How Functional Programming addresses concurrent increment/decrement operations invoked by different users?

Using Functional language, How can 2 different parties achieve the result of increment/decrement operations concurrently? For the below scenario, Let's say, I've 2 quantities in stock and 2 users in ...
Vicky's user avatar
  • 399
37 votes
7 answers
9k views

What are the functional equivalents of imperative break statements and other loop checks?

Let's say, I've the below logic. How to write that in Functional Programming? public int doSomeCalc(int[] array) { int answer = 0; if(array!=null) { for(...
Vicky's user avatar
  • 399
2 votes
3 answers
914 views

Can functional programming used for solving problems which require randomness?

This older question tells us that in functional programming "true" randomness cannot be achieved since in FP functions are pure/idempotent and return the same value irrespective of number of ...
Vicky's user avatar
  • 399
3 votes
2 answers
283 views

Should I provide partialed functions based on API call in Clojure?

I am designing a library to wrap an API with Clojure. The API requires user credentials to authenticate user related calls. My first approach was to have functions that do each task the API can do: (...
Moon Cheesez's user avatar
3 votes
1 answer
201 views

Efficient algorithm for deducing object type dynamically based on members

I am designing a DSL (in clojure, specifically; though this question is more general than that) in which 'entities' are tracked as immutable hashes/maps, and where the 'concept' membership of an ...
nben's user avatar
  • 345
3 votes
0 answers
428 views

Clojure: Decomposing Logging, Metrics, and Business Logic from a Function

I was reading the post A Modern Architecture for FP that included a code snippet that the author wanted to decompose further. I don't know Haskell but I recognize enough to know that I've written many ...
MonkeyWithDarts's user avatar
12 votes
1 answer
2k views

What practical problem results from lack of hygienic macros in Clojure?

I've heard that Clojure macros are easier to write but not as reliable as Racket's hygienic macros. My question has 2 parts: How does gensym differ from hygienic macros? What do Racket macros provide ...
Alex's user avatar
  • 284
14 votes
3 answers
5k views

If you can use def to redefine variables how is that considered immutable?

Trying to learn Clojure and you can't help but be told continually how Clojure is all about immutable data. But you can easily redefine a variable by using def right? I get that Clojure developers ...
Evan Zamir's user avatar
2 votes
0 answers
381 views

Implement FSM explicitly in re-frame/reagent/react?

I'm in the process of making a simple game using re-frame (and thus react and reagent), but I'm stuck at one point. In https://github.com/Day8/re-frame#control-via-fsm they claim Not every app ...
NiklasJ's user avatar
  • 675
3 votes
1 answer
177 views

How can you write an activation function in a neural network to handle a layer architecture of arbitrary dimensions?

I am making a neural network in Clojure that can take an array of integers,and return a data structure representing the layers of a neural network: so (make-layers [1 4 5]) would evaluate to: [[0] ...
kurofune's user avatar
  • 290
1 vote
1 answer
209 views

Clojure NameSpace Design

I am new to Clojure and trying to get a handle on organizing a project's namespaces. I am working on a solver for the knapsack problem. Currently, I have broken the modules into files, but everything ...
ben rudgers's user avatar

15 30 50 per page
1
2 3 4 5
7