Questions tagged [clojure]
Clojure is a general-purpose language supporting interactive development that encourages a functional programming style, and simplifies multithreaded programming.
91 questions
-3
votes
2
answers
157
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 ...
-2
votes
1
answer
505
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 ...
1
vote
2
answers
921
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 ...
2
votes
3
answers
968
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 ...
3
votes
1
answer
208
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 ...
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 ...
2
votes
0
answers
390
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 ...
1
vote
1
answer
222
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 ...
25
votes
7
answers
17k
views
"Use map instead of class to represent data" -Rich Hickey
In this video by Rich Hickey, the Clojure creator, he advises to use map to represent data instead of using a class to represent it, as done in Java. I don't understand how it can be better, since how ...
1
vote
1
answer
825
views
What was the influence of Chris Okasaki's data structures on Scala? [closed]
I heard a friend say:
The first real use of Chris Okasaki's book was in Clojure's data structures
I heard another friend say:
No, they influenced the design of Scala in quite a subtle way.
My ...
7
votes
2
answers
521
views
How to represent hard-to-calculate "properties" of "objects" in functional code?
I have a polyline "class" in my Clojure program, which is represented by a vector of points. (It's not really a class or anything.)
The polyline's length (in the geometric sense) is something that is ...
2
votes
1
answer
610
views
Hot swap/plug components in clojure?
I'm using OSGi for some time and I really like the ability to swap/replace components while my application is running. I simply have to build my module and push it to the OSGi container.
Is there a ...
4
votes
2
answers
463
views
Evaluation order of expressions in Clojure?
I'm currently learning Clojure (my first functional programming language), and I'm curious as to its order of evaluation.
Here is an example:
(take 10 (cycle [1 2 3]))
If the cycle expression was ...
3
votes
3
answers
2k
views
Lisp/Clojure: Removing unnecessary parentheses through conventions
I am fascinated to Lisp as it is simple yet powerful. I am just a beginner and I know there have been lots of discussions on removing parentheses from Lisp and its dialects. Yet I request Lisp ninja's ...
7
votes
1
answer
1k
views
Is it fair to say that "macros don't compose"?
On this blog post aphyr (who is a brilliant programmer) states:
Clojure macros come with some important restrictions. Because they’re expanded prior to evaluation, macros are invisible to functions. ...
4
votes
3
answers
331
views
Is there a reason for the crossover from the Ruby community to the Clojure Community?
When we look at the the overlap between the Ruby Community - we see the following overlaps:
Think Relevance (now Cognitect) has switched from Ruby to Clojure
Jay Fields has switched from Ruby to ...
7
votes
1
answer
2k
views
How to refactor a Java singleton to Clojure?
I'm writing a simple game in Java and I want to learn Clojure, so I've decided to refactor my current Java code to Clojure. The problem is that I've coded so much in object-oriented languages that I ...
8
votes
3
answers
1k
views
Why does Clojure neglect the uniform access principle?
My background is Ruby, C#, JavaScript and Java. And now I'm learning Clojure. What makes me feel uncomfortable about the later is that idiomatic Clojure seems to neglect the Uniform access principle (...
46
votes
6
answers
10k
views
Why is "tight coupling between functions and data" bad?
I found this quote in "The Joy of Clojure" on p. 32, but someone said the same thing to me over dinner last week and I've heard it other places as well:
[A] downside to object-oriented programming ...
0
votes
1
answer
2k
views
Is Clojure development required to be open-source?
This question could be generalized to any language where the language development is open-source, potentially, but I'm most curious about Clojure specifically.
If Clojure (as a language) is open-...
8
votes
3
answers
3k
views
When would I require a Macro instead of a function?
I am new to Clojure, I am new to Macros and I have no prior background in Lisp.
I went on to create my own switch case like form and ended up with this:
(defmacro switch-case [v cases default] (if (...
0
votes
2
answers
527
views
Are there any Clojure libraries for p2p? [closed]
I'm a web developer, but lately I have been learning Clojure and now I'm interested in creating a p2p application. And since Clojure is a general purpose language, I guess I can just use that.
Any ...
14
votes
1
answer
4k
views
How to write readable Clojure Code?
I am new to Clojure. I can understand the code I write but it becomes too difficult to understand it later.It becomes difficult to match parentheses.
What are the generic conventions to follow ...
10
votes
2
answers
2k
views
Is Haskell/Clojure actually unsuited for dynamic systems such as particle simulation?
I've been told in previous questions that functional programming languages are unsuited for dynamic systems such as a physics engine, mainly because it's costly to mutate objects. How realistic is ...
3
votes
2
answers
2k
views
clojure/erlang/go for high volume server
I have a project that will need to handle 1000s of requests a second with a decent amount of processing for each. For the most part, the processing will be done on a list of items, basically ...