Skip to main content

All Questions

-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
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
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 ...
MaiaVictor's user avatar
  • 5,850
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 ...
MaiaVictor's user avatar
  • 5,850
6 votes
2 answers
304 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 ...
case nelson's user avatar
26 votes
3 answers
2k 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 ...
Michael Spector's user avatar