All Questions
Tagged with functional-programming javascript
50 questions
0
votes
3
answers
235
views
How to filter "locally and remotely" in functional programming
My example applies to reading and deleting files (I/O), but this is probably a common scenario (eg, keeping local and global state in sync in functional programming).
I am reading in files from a ...
3
votes
3
answers
304
views
How to "pass through" data in a functional programming pipeline so that it's accessible later on in the pipeline
I am trying to refactor some JavaScript code to use functional programming principles.
I have some functions that I want to use in a series of maps.
const transformedData = rawData
.map(...
5
votes
3
answers
616
views
Are "pipelines" in functional programming bad for time complexity?
This question is not meant to be a critique of functional programming, but more hoping for resources and opinions.
I am refactoring some historically messy code so that it follows functional ...
1
vote
2
answers
325
views
Why did TC39 name JavaScript's array predicate functions `some` and `every` instead of `any` and `all`?
Python, Ruby, Rust, Haskell, Kotlin, C#, C++, Perl, MATLAB, SQL, and R all call their respective array predicate checking functions any and all.
Is there any record of why JavaScript's designers ...
0
votes
2
answers
759
views
Should I use unnecessary function for readability sake
I am implementing if/else statement, by using function "inCase" to make it more readable:
const size = 'small'
const equals = str1 => str2 => str2 === str1
const inCase = (obj) => ...
4
votes
3
answers
963
views
Is this extensive usage of closure a known (anti-)pattern? And does it have a name?
I often use function closures for storing data (e.g. database URL), which doesn't change between function calls. Is this an (anti-)pattern? Does it have a name?
While developing apps, which recieve ...
16
votes
10
answers
7k
views
Are immutable objects important only in multi-threaded applications and if so, how are shared immutable objects useful?
I think the answer to the first part of my question is, "yes" -- no point in making objects immutable in a single-threaded application (or I guess in a multi-threaded application if that ...
12
votes
2
answers
5k
views
A real-life example of using curry function? [closed]
I was struggled to find a real-life example of using curry function and get the benefit of using curry.
When I google curry function I often see the example like
let add = x => y => x + y;
let ...
1
vote
4
answers
471
views
In Haskell, is it a "violation" of functional programming to interact with something that was not a function parameter?
I'm sure this must have been asked before, but I can't find anywhere that actually answers my question, so apologies if I have simply overlooked this.
I am currently learning Haskell, and loving the ...
3
votes
1
answer
1k
views
How do functional programming advocates use a framework like React or Angular?
I read this blog post recently:
The Two Pillars of JavaScript
Part 1: How to Escape the 7th Circle of Hell, which is essentially a criticism of object oriented programming, and advocacy for funtional ...
0
votes
1
answer
177
views
Is the usage of flip function a smell for bad design?
Everything is in the title, is the usage of flip function a smell for bad design ?
I'm coming from a JavaScript universe and used to work with lodash/fp or ramda.
Recently, I've written some stuff ...
1
vote
0
answers
563
views
Understanding transducers, why this is not a transducer
I'm currently learning functional programming and trying to learn a new concept : transducers.
I'm actually getting the point of theory, like it's an advanced map/reduce that aims to provide better ...
10
votes
1
answer
796
views
Why most anonymous functions can't be JIT compiled and will never be optimized?
I just read https://techfindings.one/archives/2652 about functional programming and came accross this:
anonymous functions can often not be JIT compiled and will never be
optimized
Can someone ...
4
votes
2
answers
484
views
What are the correct functional programming terms for what I'm doing here?
I recently needed a function to deep clone an object. I started with the code given as an accepted answer to this question: https://stackoverflow.com/a/728694/1253156
However, our SonarQube ...
9
votes
2
answers
791
views
How can I _read_ functional JavaScript code?
I believe I have learned some/many/most of the basic concepts underlying functional programming in JavaScript. However, I have trouble specifically reading functional code, even code I've written, and ...