Skip to main content

Questions tagged [functional-programming]

Functional programming is a paradigm which attempts to solve computational problems by the chained evaluation of functions whose output is determined by their inputs rather than the programme state. In this style of programming, side effects and mutable data are deprecated and usually strictly isolated.

Filter by
Sorted by
Tagged with
-1 votes
1 answer
165 views

I had been using react-js and really like its concept so I want to know if there is a programming language/framework that sort of works like it. For instance, I want to define: var A = something var ...
letFunny's user avatar
2 votes
1 answer
304 views

I have a large number of record types derived from a binary format specification. So far, I've already written a computation expression builder that let’s me read structures from the files easily: ...
Kevin Li's user avatar
  • 145
1 vote
3 answers
258 views

If I could get some input on the design of this, I would be grateful as well. Note that I'm programming in python. There's a function F that takes lots of data, runs some analysis on it (taking ...
chausies's user avatar
  • 165
3 votes
2 answers
3k views

I started studying functional programming with JavaScript. After this, I started to study it with Java 8 (streams, lambdas and method reference) and I realised that I tend to use streams as much as ...
Bruno Carneiro's user avatar
13 votes
6 answers
3k views

I know this can be very use-case specific, but I find myself wondering this far too often. Is there a generally preferred syntax. I'm not asking what is the best approach when in a function, I am ...
Matthew Mullin's user avatar
2 votes
3 answers
501 views

I come from OOP pradigm and I also know a bit about functional programming and its advantages. Over time I came to like the separation of data and transformations that are applied to it using pure ...
konrad's user avatar
  • 551
2 votes
2 answers
161 views

According to Is it OK to split long functions and methods into smaller ones even though they won't be called by anything else?, I should split long functions into smaller functions even if they ...
ocomfd's user avatar
  • 5,760
0 votes
3 answers
604 views

I couldn't find a question on SE but it has probably been asked elsewhere already (in case, please mark it). A method containing code to run just with specific external conditions can: decide whether ...
Kamafeather's user avatar
-1 votes
2 answers
204 views

The more declarative code is, the less explicit technical details it contains and the closer it gets to requirements expressed in domain language. In the extreme case, there is no more difference ...
Frank Puffer's user avatar
  • 6,459
4 votes
2 answers
223 views

For example, suppose my input data and UI is not in 1 to 1 relationship: html: <script> aChanged=function(){ }; bChanged=function(){ }; cChanged=function(){ }; </script> a:<input id="...
ocomfd's user avatar
  • 5,760
6 votes
2 answers
1k views

This question is related but doesn't directly answer my question. I can imagine that understanding category theory helps someone who is designing a programming language, apparently in particular ...
user56834's user avatar
  • 195
1 vote
1 answer
220 views

Consider a "large-ish" data set (~2-5M rows) that goes through multiple stages of cleaning/processing: library(dplyr) largedat %>% mutate( # overwrite v1 based on others v1 = somefunc(...
r2evans's user avatar
  • 346
0 votes
4 answers
255 views

context and background: I prefer OOP for the most part and find it, largely, more intuitive -- this is my bias. When I read that functional language x is better than OOP language y I think to myself:...
Thufir's user avatar
  • 224
12 votes
2 answers
5k views

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 ...
Qiulang 邱朗's user avatar
0 votes
1 answer
249 views

Consider I have a list. I want to iterate over it and map it's elements -- but the mapping might also require to change others than the element I'm currently iterating over. Let's say I have a switch ...
Coderino Javarino's user avatar
7 votes
2 answers
1k views

I am from OO background just started learning FP paradigm. Came across quote by Michael Feathers - "OO makes code understandable by encapsulating moving parts. FP makes code understandable by ...
rahulaga-msft's user avatar
1 vote
5 answers
2k views

Say I have a TypeScript class: export class TypeCreator { entities: Set<Whatever> registerEntities(e: Set<Whatever>): Set<Whatever>{ return this.entities = e; } } if ...
user avatar
-1 votes
1 answer
158 views

I'm struggling to understand how a ReactiveX operator can be considered functional. Operators are implemented as functions, but but with the exception of simple operators like map and reduce many of ...
Brian Flynn's user avatar
2 votes
1 answer
2k views

I would like to be able to implement immutable data in C++. In short, given a C++ object in which I would like to modify a member variable, instead of modifying that member in place I would like to ...
Rulle's user avatar
  • 181
12 votes
4 answers
3k views

If my function meets the two requirements listed below, I believe that the function Sum returns the summation of the items in a list, where item evaluates as true for a given condition. Doesn't this ...
rahulaga-msft's user avatar
0 votes
1 answer
400 views

Functional programming strongly suggests to separate data from behaviours (functions). However, I can't see the benefit of this for an algorithm's implementation intrinsically tied with particular ...
schrödingcöder's user avatar
4 votes
2 answers
315 views

I found a function in c# like this: private Dictionary<string, Func<string>> ObtenerExtraCfgCampo(MsgDefCamp camp) { var extra = new Dictionary<string, Func<string>&...
Adrian Godoy's user avatar
3 votes
1 answer
498 views

As a developer who has primarily been doing functional programming in F# for the last several years, I'm very attached to my REPL and use it run my code as I go, testing and refining each function as ...
InitialValue's user avatar
1 vote
4 answers
499 views

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 ...
Raiden616's user avatar
  • 141
0 votes
1 answer
212 views

Haskell is one of the few non-strict languages out there. In his paper Why Functional Programming Matters, John Hughes uses (memoized) lazy evaluation (as well as higher-order functions) to implement ...
Qqwy's user avatar
  • 4,947
5 votes
3 answers
2k views

In context of pure functions in FP, apart from several benefits mentioned like easy to reason about, testability it also says "order of evaluation does not matter" since output remains same for given ...
rahulaga-msft's user avatar
3 votes
1 answer
1k views

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 ...
dwjohnston's user avatar
  • 2,769
2 votes
3 answers
3k views

The java.util.Predicate interface contains the test(...) method, whose JavaDoc description states that it [evaluates] this predicate on the given argument and that it [returns] true if the input ...
Tudor Timi's user avatar
2 votes
1 answer
906 views

Introduction We need to design a system that, given a set of events that are happening in the source application, reacts to them and if some conditions have been met, actions can be triggered. Users ...
Jacob's user avatar
  • 321
2 votes
0 answers
474 views

I'm designing a type in C# that will be used as an algebraic type in a functional style, but is not a collection type and does not implement IEnumerable. If this type is a Functor, should I name its ...
JounceCracklePop's user avatar
4 votes
1 answer
3k views

Are there 'conventions' / best practices on naming pure functions? For example: adding numbers: add or sum? calculating the square root: calcSqrt or sqrt? reversing a list: reverse or reversed? ...
Willem-Aart's user avatar
1 vote
2 answers
159 views

Suppose we need an iterative algorithm for mathematical optimisation. Each iteration takes a long and random time. After each iteration, a stopping condition is checked for the iterate x, based on ...
schrödingcöder's user avatar
0 votes
1 answer
183 views

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 ...
mfrachet's user avatar
  • 1,591
2 votes
2 answers
2k views

A frequent pattern in my Haskell code is element-wise recursion for transformation of a list with some carried state generated using the data in the list. Usually, this looks something like this: ...
TheEnvironmentalist's user avatar
4 votes
1 answer
846 views

Functional languages seek to minimize accidental state (computationally-convenient but logically unnecessary data dependencies) by endorsing the most granularly modular, mathematically unambiguous ...
Typist's user avatar
  • 49
0 votes
1 answer
139 views

Using C# as an example, extensions on IEnumerable to allow code like collection.Each(i => i.DoStuff) rather than a foreach loop are generally frowned upon, mainly because they don't follow LINQ ...
GoatInTheMachine's user avatar
3 votes
2 answers
744 views

In a video about software architecture that I'm watching, it's stated that the main program/subroutine architectural style promotes modularity and function reuse Code reuse is one of the main ...
antonro's user avatar
  • 249
4 votes
2 answers
2k views

I understand concept data abstraction as it is relevant to OO programming. However on contrary it seems Function Programming promotes or makes use of concept control abstraction. I tried searching ...
rahulaga-msft's user avatar
4 votes
4 answers
975 views

Trying to see if immutability is a good fit for highly dynamic objects like game entities (that constantly are moving around and changing) or particle systems, each which might have thousands or ...
Lance Pollard's user avatar
9 votes
7 answers
4k views

I can see the benefits of mutable vs immutable objects like immutable objects take away lot of hard to troubleshoot issues in multi threaded programming due to shared and writeable state. On the ...
rahulaga-msft's user avatar
11 votes
3 answers
5k views

According to Wikipedia, Functional programming languages, that are Declarative, they disallow side effects. Declarative programming in general, attempts to minimize or eliminate side effects. Also, ...
codebot's user avatar
  • 221
1 vote
0 answers
571 views

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 ...
mfrachet's user avatar
  • 1,591
4 votes
2 answers
776 views

I've been reading Out of the Tar Pit by Ben Moseley and Peter Marks and in section 5.2.3 they discuss state in functional languages compared to procedural languages. The procedural example is as ...
Karl Uibo's user avatar
  • 153
17 votes
2 answers
10k views

In the book Coders at work Joe Armstrong stated that: I think the lack of reusability comes in object oriented languages, not in functional languages. Because the problem with object oriented ...
Kha Nguyễn's user avatar
3 votes
2 answers
2k views

After reading and using different concepts(right or wrong) questions related to modularity have appeared. I want to implement the microservice architecture in my projects the right way. As from ...
DaAmidza's user avatar
  • 159
2 votes
1 answer
199 views

Let's say you have a tic-tac-toe app. There's the game state which can be represented by an array of size 9. There's your "reducer" computes new state from old state and player actions. Then there's ...
Joseph's user avatar
  • 657
14 votes
3 answers
3k views

This past year I took the leap and learned a functional programming language (F#) and one of the more interesting things that I've found is how it affects the way I design OO software. The two things ...
Patrick D's user avatar
  • 271
1 vote
2 answers
305 views

Update: I added some diagrams to help understanding I had a discussion with a colleague about two different approaches in mapping data objects. I'd like to get your opinion on pros and cons between ...
Nikolaos Georgiou's user avatar
1 vote
3 answers
3k views

When implementing a DDD driven system (based on event sourcing) using a functional programming language (Clojure), should one separate event handler functions from aggregate functions? In my naive ...
Witek's user avatar
  • 237
1 vote
2 answers
274 views

public static Func<string, Task<T>> MyMethod<T>( UserCredentials credentials, Func<string, string, string, Task<T>> func ) => async (value) ...
Yatrix's user avatar
  • 335

1 2
3
4 5
15