All Questions
Tagged with functional-programming javascript
50 questions
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 ...
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(...
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 ...
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 ...
111
votes
3
answers
16k
views
Why do Trampolines work?
I've been doing some functional JavaScript. I had thought that Tail-Call Optimization had been implemented, but as it turns out I was wrong. Thus, I've had to teach myself Trampolining. After a bit of ...
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) => ...
23
votes
5
answers
4k
views
What is the benefit of having "no runtime errors", like Elm claims?
Some languages claim to have "no runtime errors" as a clear advantage over other languages that has them.
I am confused on the matter.
Runtime error is just a tool, as far as I know, and ...
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 ...
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 ...
6
votes
3
answers
2k
views
What is the name for a NON-self-calling function?
I have a collection of normal functions and self-calling functions within a javascript file. In my comments i want to say something along the lines of "This script can contain both self-calling and ...
31
votes
5
answers
33k
views
Performance: recursion vs. iteration in Javascript
I have read recently some articles (e.g. http://dailyjs.com/2012/09/14/functional-programming/) about the functional aspects of Javascript and the relationship between Scheme and Javascript (the ...
36
votes
5
answers
34k
views
Is Javascript a Functional Programming Language
Is Javascript a functional language? I know it has objects & you can do OOP with it also, but is it also a functional language, can it be used in that way?
You know how OOP became/seems like the ...
9
votes
3
answers
3k
views
Is a function getting a value from another function considered pure?
I'm trying to figure out a way to handle default variable values when making functions without side effects and have ended up with the following:
function getDefaultSeparator() {
return ':';
}
...
26
votes
1
answer
4k
views
Are generator functions valid in functional programming?
The questions are:
Do generators break the functional programming paradigm? Why or why not?
If yes, can generators be used in functional programming and how?
Consider the following:
function * ...