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
24 votes
4 answers
13k views

I often find myself writing functions that look like this because they allow me to easily mock data access, and still provide a signature that accepts parameters to determine what data to access. ...
NightWatchman's user avatar
5 votes
1 answer
583 views

I recently built a small web application using riotjs, a library that facilitates creating UIs in the spirit of functional reactive programming, i.e. defining the UI as a pure function of the ...
ammut's user avatar
  • 159
8 votes
2 answers
2k views

I'm reading about pure-functions in functional programming and am wondering, whether a function being deterministic implies that the function is also side-effect free? (and vice versa?)
user66875's user avatar
  • 191
1 vote
1 answer
208 views

We need to get more much more rigorous about managing state in our business application. The heart of our problem is an object, lets call it an "TaxRefundApplication", that has about 20 properties, ...
bbsimonbb's user avatar
  • 749
4 votes
1 answer
489 views

All tutorials on GADTs that I've seen (in Haskell, Coq and Idris) use one same exapmle of a well-typed interpreter to show how GADTs can be useful, where you use the type index to encode the type of ...
Alex's user avatar
  • 284
4 votes
2 answers
508 views

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 ...
Patrick Hund's user avatar
1 vote
2 answers
2k views

I am posting because, first of all, I want to make sure my understanding on these 3 methodologies is correct. Secondly, I would like some clarification on how they could all fit in together. I see ...
bitterman's user avatar
  • 177
9 votes
2 answers
810 views

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 ...
Andrew Willems's user avatar
4 votes
2 answers
1k views

As a beginner in both java8 and functional programming, I think I'm missing something when reading about function composition since I cannot find a reason why there are two methods that do this, ...
Ioanna's user avatar
  • 163
3 votes
1 answer
764 views

I was reading Death of for-loop article, and I thought maybe I should timeit the codes. I created this benchmark at jsperf which clearly shows that map-filter approach is about 90% slower. So, why is ...
Harsh Gupta's user avatar
3 votes
1 answer
1k views

I wonder whether a method in a functional programming language should receive all variables from the argument list, or whether it is ok to use variables from the outer scope? But let me explain the ...
Raphael Roth's user avatar
4 votes
3 answers
902 views

Is a total, impure function considered to be Referentially Transparent (RT)? Example: // Given an 'id', try to retrieve an optional Person // from the database, i.e. side-effect. // Note that '...
Kevin Meredith's user avatar
2 votes
2 answers
4k views

In functional languages without type checking, is there any substantial disadvantage (apart from readability) to limiting all functions to take exactly one argument - that is, replacing multi-argument ...
max's user avatar
  • 1,115
3 votes
3 answers
1k views

I come from an object oriented programming background, therefore, I am pretty curious about the core philosophy of functional programming? Why does it exist at the first place, and what types problems ...
Fatima's user avatar
  • 209
10 votes
1 answer
2k views

From the interview with Kent Beck in a recent Java Magazine issue: Binstock: Let’s discuss microservices. It seems to me that test-first on microservices would become complicated in the sense that ...
Dan's user avatar
  • 221
2 votes
0 answers
197 views

I have this two types open FSharpx open FSharpx.Reader type First = { Name: string Items: string list } type Second = { Name: string Numbers: int list } Using a Reader monad ...
fra9001's user avatar
  • 121
-1 votes
1 answer
95 views

I'm building a custom Notification section, which provides notification or messages to multiple users on any particular object update, I've created a HTML page like Dashboard where I have added a ...
user2809299's user avatar
2 votes
1 answer
130 views

Let's say I'm programming a chess game. At some point I have to check, which moves are valid for a given piece. What would be the proper way to select the correct pathfinding function for a given ...
user avatar
5 votes
3 answers
657 views

Objects tend to confuse me some. In understand the concept and use, certainly, but I feel like the functional paradigm is somewhat restricting my use of them. At the moment, I'm creating a simple ...
Ucenna's user avatar
  • 1,312
23 votes
5 answers
4k views

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 ...
atoth's user avatar
  • 539
4 votes
1 answer
444 views

There are huge benefits to pure functions in functional programming, but can the same benefits be obtained in imperative programming with heavy use of the service pattern? I ask because I want to ...
clinux's user avatar
  • 287
6 votes
1 answer
629 views

How can Gary Bernhardt's "Functional Core / Imperative Shell" architecture be used to design software for an elevator system? Specifically, let's say there are a few elevators, each with call buttons ...
max's user avatar
  • 1,115
1 vote
0 answers
344 views

During its evolution C# gradually gets more and more features which belong to functional paradigm. Subjectively these features allow (at least me) to be more productive, fluent and write maintainable ...
Pavel Voronin's user avatar
19 votes
4 answers
4k views

In programming, what are the benefits of referential transparency? RT makes one of the major differences between functional and imperative paradigms, and is often used by advocates of the functional ...
Eyal Roth's user avatar
  • 623
3 votes
0 answers
441 views

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 ...
MonkeyWithDarts's user avatar
4 votes
1 answer
694 views

I would like to solicit some general design principles and best practices to avoid creating a callback pyramid of doom particularly in the Scala language. Consider the following rudimentary and ...
Coder Guy's user avatar
  • 727
2 votes
1 answer
758 views

A trace table is a technique used to test algorithms. "The table usually takes the form of a multi-column, multi-row table; With each column showing a variable, and each row showing each number ...
Alexandre Demelas's user avatar
11 votes
1 answer
8k views

I'm not finding via Google any explanation that my brain can grasp. Can someone explain this, and if possible, give an example of each using either pseudocode or C#? The term 'total' function was ...
Rock Anthony Johnson's user avatar
26 votes
4 answers
9k views

I've been told that in functional programming one is not supposed to throw and/or observe exceptions. Instead an erroneous calculation should be evaluated as a bottom value. In Python (or other ...
Eli Korvigo's user avatar
28 votes
5 answers
4k views

The following code examples provide context to my question. The Room class is initialized with a delegate. In the first implementation of the Room class, there are no guards against delegates that ...
Rock Anthony Johnson's user avatar
4 votes
1 answer
250 views

This question is followup to this question. Is there any benefit in avoiding the 'this' operator when implementing pure methods? That is, are there any advantages to making all dependencies explicit ...
Rock Anthony Johnson's user avatar
27 votes
5 answers
4k views

In the following code example, we have an class for immutable objects that represents a room. North, South, East, and West represent exits into other rooms. public sealed class Room { public Room(...
Rock Anthony Johnson's user avatar
2 votes
6 answers
848 views

I'm new to compiled languages. I'm learning C. I'm used to coding in python. I was wondering if there was any equivalent, or replacement method in compiled langues for functions able to create a ...
loxaxs's user avatar
  • 147
-7 votes
1 answer
155 views

In internal computer memory Char value ,string and integer how they differentiate time of storing and retrieving . Char A =ASCI value 127 Int value 127 Binary is same then how computer understand ...
user3550931's user avatar
0 votes
2 answers
246 views

I'm a data analyst, not a software developer, and I often find myself writing a function like this (shown in Python syntax here): def apply_many(arg, *funcs): return [func(arg) for func in funcs] ...
shadowtalker's user avatar
112 votes
3 answers
16k views

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 ...
Ucenna's user avatar
  • 1,312
6 votes
1 answer
840 views

From Kelvin Murphy's review on Algorithms (4th Edition) by Sedgewick and Wayne For data structures, it is obviously natural to use classes, but they also adopt this approach for many algorithms, ...
Tim's user avatar
  • 5,565
0 votes
3 answers
287 views

If I have pure functional programming language with* very very smart optimization* proccess, is it possible to reason about memory usage, just by looking at type signature? add :: Int -> [Int] -&...
Ford O.'s user avatar
  • 223
16 votes
3 answers
5k views

I heard somebody say their language has a convention where the names of functions which mutate state must end with an exclamation point. I'm trying to write more functional code and I like the idea of ...
Roger Heathcote's user avatar
26 votes
1 answer
4k views

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 * ...
Pete's user avatar
  • 1,247
1 vote
1 answer
1k views

I've been learning functional programming in javascript of late, and there's one thing that's been confusing me. I can't quite understand if it's ever okay to redefine variables. Something like: a = ...
Ucenna's user avatar
  • 1,312
3 votes
2 answers
2k views

I've recently gotten into functional programming. I asked a question earlier over here "'Remembering' values in functional programming" and learned a lot of things I hadn't even realized I wanted to ...
Ucenna's user avatar
  • 1,312
7 votes
1 answer
1k views

For instance, array.map accepts a callback that returns a value. const newArray = oldArray.map(item => doSomethingTo(item)); Promises also accept callbacks that return a value. const ...
Joseph's user avatar
  • 657
21 votes
4 answers
6k views

I've decided to take upon myself the task of learning functional programming. So far it's been a blast, and I've 'seen the light' as it were. Unfortunately, I don't actually know any functional ...
Ucenna's user avatar
  • 1,312
2 votes
2 answers
655 views

I have a struct called State which holds all the variables for the program. Rather than being modified by functions directly, it is the value returned. Here is some code: #define USERNAME_LENGTH 20 #...
ridthyself's user avatar
3 votes
1 answer
284 views

It seems that the standard practice is to immediately alias MailboxProcessor<'T> to Agent<'T>. So why the name in the first place anyways? Why don't they just call it Agent<'T>, if ...
xji's user avatar
  • 791
2 votes
1 answer
349 views

Excuse my ignorance, I come from the C family of languages but zero exposure to functional languages. I've read that pure functions only generate output based on a given input. Same input gives the ...
Joseph's user avatar
  • 657
17 votes
4 answers
4k views

One of the important concepts in Object Oriented Programming is Encapsulation. However, lately the software world seems to be tilting in favour of other paradigms like functional programming. It ...
JeffV's user avatar
  • 415
0 votes
1 answer
126 views

I'm would like to know your opinion of what is an ideomatic way writing a OR function in functional reactive programming. That is, if I have x number of signals which can return a truthy or falsy ...
Erik Johansson's user avatar
2 votes
2 answers
853 views

Hypothetical situation - can a currying function have an unknown number of arguments (kind of like varargs) Eg in Python: addByCurrying(1)(2)(3)(4) Should equal 10 addByCurrying(5)(6) Should equal ...
vikarjramun's user avatar

1
3 4
5
6 7
15