Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.

Questions tagged [functional-programming]

Use this tag for programs where "functional" style is important - likely making use of function composition and without side-effects. NOT simply because your code contains functions!

Filter by
Sorted by
Tagged with
0 votes
0 answers
44 views

I am looking for a good way to structure my Kotlin code using Spring Boot 4 and Spring 7. The new features I am using are: Reflectionless dependency injection via ...
Alexander Petrov's user avatar
0 votes
0 answers
51 views

haskeline is a reimplementation in haskell of the GNU Readline library (the one that by default allows you to delete the word you just typed on your shell's command line by pressing Ctrl+w, for ...
Enlico's user avatar
  • 531
4 votes
1 answer
138 views

Also posted on Reddit. As a small personal exercise, I'm trying to implement a notion of higher-kinded types in Rust using type-level defunctionalisation based on the "Lightweight higher-kinded ...
nicoty's user avatar
  • 329
2 votes
2 answers
150 views

I am trying to manage state in vanilla JavaScript—without using frameworks like React or Vue. I am also not using state management libraries. My requirements are: Reactivity Time Travel (Undo/Redo) ...
Ahmad Ismail's user avatar
5 votes
1 answer
145 views

In my application there are many business workflows. Most of them are quite simple and can be put in one function. A few of them however are very complex and have many business validations, require ...
Parsa99's user avatar
  • 267
3 votes
2 answers
161 views

Introduction The following code is an implementation of, in ambition, RFC 4648 compliant Base16, Base32 and Base64 conversions as range adaptors and constrained algorithms in C++23. It can be used at ...
nilo's user avatar
  • 805
2 votes
0 answers
107 views

This increment This obsoletes a former version, after taking a great review into account: The encoding now preserves sized_range and ...
nilo's user avatar
  • 805
3 votes
1 answer
208 views

Edit: obsoleted by an improved version. Edit: now updated with unit tests that show that this implementation also works for non-forward ranges, i.e. string streams, files streams, on-the-fly encoding/...
nilo's user avatar
  • 805
4 votes
2 answers
385 views

This obsoletes a former version and is obsoleted by an improved version. The following code is an implementation of, in ambition, RFC 4648 compliant Base16 conversions as range adaptors in C++23. It ...
nilo's user avatar
  • 805
4 votes
1 answer
236 views

This is obsoleted by a significantly better version. The following code is an implementation of hexadecimal conversions as range adaptors in C++23. It can be used at compile time, but should of course ...
nilo's user avatar
  • 805
5 votes
3 answers
307 views

The question asked is very straight-forward and is simple enough to solve. What I am looking for is that hopefully I can get some understanding for using the constructs and built-ins of the Haskell ...
tijko's user avatar
  • 782
5 votes
6 answers
492 views

I have a simple list of results, and I need to return only one value depending on content, for example: ...
zond's user avatar
  • 151
3 votes
1 answer
437 views

An event source built around an observer design pattern implementation… ...
user avatar
1 vote
1 answer
91 views

Temporary storing the element(s) returned by document.querySelector and document.querySelectorAll methods could improve ...
user avatar
8 votes
1 answer
144 views

I want to get better at functional programming so I started with this simple 2-player TicTacToe game. Next I want to add a simple min-max algorithm to make it a 1-player game, but before that I'd like ...
Peter's user avatar
  • 183
8 votes
3 answers
2k views

I implemented a simple fmap for containers. However containers don't have a unified function to add elements. So I wrote different concepts for different containers. Is there a better way to implement ...
Yu Cong's user avatar
  • 83
3 votes
1 answer
131 views

I want to replace a for loop with a break/return condition inside with a lambda. I think I have a good replacement, but I want ...
Oscar Besga Panel's user avatar
1 vote
1 answer
98 views

Developed around visibility CSS property and HTMLElement#offsetHeight and ...
user avatar
4 votes
3 answers
265 views

I have a table of user info. When you click the button, I want to get the email address from each selected row, output into a comma-separated string. I got it to work with the following code, but I'm ...
LBF's user avatar
  • 143
7 votes
2 answers
256 views

Prior Notification This follows a previous review of mine that addressed the core helper function named make_skippable. The composition implementation presented ...
mahush's user avatar
  • 115
3 votes
2 answers
182 views

(Please note: the post about the compose implementation announced below is now available.) This is about decorating callables by making their argument and return value to be a ...
mahush's user avatar
  • 115
3 votes
2 answers
206 views

I'm an autodidact working on map coloring algorithms with backtracking, see chapter 2 of this book. I tested this implementation with success but I'm still unsure whether it is tricking me somewhere, ...
deppep's user avatar
  • 33
5 votes
1 answer
142 views

I am using the Advent of Code 2023 to study functional programming and the ranges library in C++. This code is for the second part of Day 3 and is the best solution using FB I've created. I'd ...
Rud48's user avatar
  • 225
4 votes
1 answer
131 views

I am exploring functional programming design with C++. The code below uses a struct passed to ranges::fold_left for processing. The final result is returned in the ...
Rud48's user avatar
  • 225
2 votes
1 answer
127 views

I've been battling ChatGPT for hours now and can't get satisfied with this simple algorithm in TypeScript. These two (hopefully correct) TypeScript+ReactNative solutions should move the timestamp ...
Slazer's user avatar
  • 121
5 votes
2 answers
170 views

The three characters that occurs most in a given string should be printed by using streams/lambdas (functional programming). The order of characters that occur equally often should be preserved. My ...
Tobias Grothe's user avatar
2 votes
1 answer
124 views

Util class to find into a collection the indexes of a given element with multiple occurrences from the first index or relative to a given index. ...
user avatar
4 votes
4 answers
1k views

I have written a Python function called merge_arrays which takes two lists and returns the new list merge without duplicate. The function works as expected, but my ...
TAHER El Mehdi's user avatar
2 votes
1 answer
139 views

This is a interview practice question from BFE.dev. Currying is a useful technique used in JavaScript applications. Please implement a curry() function, which ...
Christopher Fimbel's user avatar
1 vote
2 answers
96 views

My question got rejected the last time so I am trying a better approach to getting a solution: ...
PyNoob's user avatar
  • 21
5 votes
1 answer
165 views

I'm trying to make a partial function from any function. Here is a working example: ...
Miroslav Popov's user avatar
1 vote
1 answer
80 views

Implementation to accommodate different behaviours based on the frequency a user interface element is clicked. It supports number of clicks and number of clicks in a time frame. ...
user275176's user avatar
4 votes
1 answer
113 views

I'm writing a small utility operator which applies two functions to an argument pair and strands the results. The pair can either be given as two arguments or as a single argument with two elements. ...
Adám's user avatar
  • 751
1 vote
2 answers
667 views

I've written a function that takes two arrays of integers as input and removes all the elements in the first array that are also present in the second array. I would like to share my code with you and ...
TAHER El Mehdi's user avatar
1 vote
1 answer
75 views

I have written a Python function to solve the Dig Pow problem, where the goal is to find a number k such that the sum of each digit of n raised to a specific and ...
TAHER El Mehdi's user avatar
7 votes
5 answers
1k views

I have written a Python function called closest_multiple_10() which takes an integer as input and returns the closest multiple of 10. The function works as expected,...
TAHER El Mehdi's user avatar
2 votes
1 answer
122 views

I am looking for a review of my Binary Tree Zipper implementation on Ocaml. These are the defined operations: get (gets the substructure, or the trees after the focus element) bempty creates an empty ...
V_head's user avatar
  • 575
0 votes
1 answer
80 views

When I write code, I tend to follow functional paradigms often. The main thing I try to do is use values returned from functions. What I notice though, is I end up having a sort of function argument ...
Vinn's user avatar
  • 127
2 votes
1 answer
94 views

I have this OCaml problem: Recall the polymorphic type lazy seen in class, the function delay which transforms a ...
V_head's user avatar
  • 575
5 votes
1 answer
951 views

Have I defined a Monad object for C++? Below is a class called var which I created years ago to implement a lambda calculus like interpreter in C++. The class ...
StormCrow's user avatar
  • 369
4 votes
7 answers
317 views

Requesting for a code review for a scala implementation. Problem Given an expression string made of numbers and operators +,-,/,* , break it in a list of Integer or ...
vikrant's user avatar
  • 405
4 votes
2 answers
214 views

I have implementted a simple JavaScript function to find the list of abundant numbers and print them on the screen. an abundant number is a number for which the sum of its proper divisors is greater ...
Napoleon Bonaparte's user avatar
1 vote
1 answer
160 views

I have a method that merges keys and indexes from an array into an object. I'm stuck with ways to compress this method, and I don't know what I can do to make it simpler. Goal get an array of objects ...
wittgenstein's user avatar
3 votes
0 answers
88 views

I have decided on a preferred solution to my question A maybe type in Python. Which implementation is best?, and have expanded it to be more ergonomic. I have implemented a host of utility functions (...
schuelermine's user avatar
1 vote
1 answer
81 views

I am working on a project in react. Where most of the data on different tabs have a table. So I design the "TableItems" component and passed the data according to the component. Right now ...
Hamid Shah's user avatar
-2 votes
1 answer
1k views

I tried so many things to do this task. I have no idea why doesn't it work. Please help! ...
user's user avatar
  • 1
2 votes
1 answer
108 views

Context Chapter 6 of Learn You A Haskell contains a function called chain, which outputs the Collatz sequence of a given input. (In short, it takes a natural number....
Jessica's user avatar
  • 910
1 vote
2 answers
234 views

Upon suggestion in the original question within Stack Overflow, I'm bringing my question here. We have created a function that will convert the data into the desired format, but it has a lot of code ...
SDK's user avatar
  • 113
1 vote
1 answer
86 views

...
Pierre Abbat's user avatar

1
2 3 4 5
21