Tagged Questions
4
votes
0answers
124 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 ...
7
votes
1answer
633 views
Pattern matching in Clojure vs Scala
What are the key differences between pattern matching in these two languages? I am not referring to syntax, but capability, implementation details, range of use cases and necessity.
Scala ...
6
votes
1answer
504 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 ...
9
votes
2answers
399 views
Where do we put “asking the world” code when we separate computation from side effects?
According to Command-Query Separation principle, as well as Thinking in Data and DDD with Clojure presentations one should separate side effects (modifying the world) from computations and decisions, ...
6
votes
2answers
631 views
How do people get rid of conditional branches in Functional Programming?
Long running switch cases or if-else-if constructs are avoided in OOP using polymorphism wherever it is applicable.
instead of branching by matching a value, branching is done at class-level itself.
...
7
votes
2answers
997 views
Could we build a functional computer?
As mush as FP has done, in the end, all our programs are structured.
That is, it doesn't matter how pure or functional we make a them - they are always translated to assembly,
so what actually runs ...
6
votes
2answers
1k 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
1answer
572 views
Is Clojure a 3GL or a 4GL?
A bit of background (in case I'm mistaken)...
I think I understand that (it's an oversimplification):
manually entering codes into memory (or on a punchcard) is "first generation language"
using ...
4
votes
2answers
224 views
Determinism of functions using PRNG in Clojure and functional languages
I'm a bit surprised by a sentence found in the book "Clojure Programming" (1st [and only as I write this!?] edition), page 78:
It should be obvious that it's impossible to deterministically test a
...
9
votes
3answers
988 views
Why can't we write nested shorthand functions in Clojure?
I tried to evaluate a Clojure expression with nested shorthand functions today, and it wouldn't let me.
The expression was:
(#(+ % (#(+ % (* % %)) %)) 5) ; sorry for the eye bleed
The output was:
...
12
votes
1answer
1k views
Does Clojure have the continuation?
I started programming with Python. When using python, concepts like coroutine, closure made me really confusing.
Now I think I know them some superficial level, but I want to get the "enlightement" ...
11
votes
3answers
1k views
Scala or Clojure Functional Programming best practices
I did a lot of self-study coding, got some experience with Parallel Programming Models: Actors, Software Transactional Memory, Data Flow.
When I am trying to apply these architectures to real life - ...
6
votes
2answers
227 views
Language that can statically ensure a map's fields are present
If data is simple and objects are complex, I'm curious if there are any existing statically typed languages that would be able to augment(?) a map type into a type with guaranteed fields. I realize ...
22
votes
3answers
1k views
Why do some functional languages need software transactional memory?
Functional languages, by definition, should not maintain state variables. Why, then, do Haskell, Clojure, and others provide software transactional memory (STM) implementations? Is there a conflict ...