Skip to main content

All Questions

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: (...
-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 ...
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(...
21 votes
3 answers
7k views

Does Clojure have continuations/coroutines/etc?

I started programming with Python, and I was really confused by concepts like coroutines and closures. Now I think I know them on some superficial level, but I've never felt that "enlightement" ...
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 ...
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 ...
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 ...
12 votes
1 answer
8k 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 ...
9 votes
3 answers
5k 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
2 answers
504 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 ...
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 ...
1 vote
1 answer
814 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 ...
11 votes
2 answers
937 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, ...
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 ...
13 votes
2 answers
4k 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 ...

15 30 50 per page