Skip to main content

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
2 votes
1 answer
131 views

This is an old script I made a while ago. What it does It tracks your dose of whatever you want tracked (cigarettes, salt, etc), outputs the total for each day, and the full week. What I’m looking for ...
Nickotine's user avatar
  • 388
2 votes
1 answer
359 views

Take the words dataset from stringr. An R4DS exercise challenges the reader to check if there are any words in that dataset that ...
J. Mini's user avatar
  • 137
3 votes
2 answers
84 views

Code ...
cgoates's user avatar
  • 185
3 votes
1 answer
330 views

this is my first F# program, very simple concept but took me a few minutes to get it. I'm new to functional programming so I'd appreciate if you could have a look ...
Santanor's user avatar
  • 131
1 vote
1 answer
146 views

I had a piece of code that solved really simple problem - it formated two dates to look better on a webpage. It looked like this: ...
Alex l.'s user avatar
  • 111
3 votes
1 answer
92 views

I have this function called error, which estimates value based on previous value and rewards in trials. The difference between the estimated value and true value is then calculated, giving the error. ...
cyrusgb's user avatar
  • 33
1 vote
1 answer
96 views

I've started learning Clojure a few days ago and I wrote this code that factorises numbers. How do I make it better? Is there any way to avoid doing it with a loop? Is that how I am supposed to code ...
Likepineapple's user avatar
2 votes
3 answers
150 views

Given the classical problem to find triplets that sum to zero in an array. Is my Scala implementation correct and executed in O(N^2)? If yes, why? Can someone make a running time analysis. What other ...
Filipe Miranda's user avatar
7 votes
1 answer
449 views

I am rather new to haskell, and could use some feedback on my code and the decisions I had to make. In my previous project, I made a JSON parser, but relied heavily on guidance from a university ...
el_micha's user avatar
0 votes
2 answers
122 views

I'm trying to understand the Functional Programming Paradigm (or style) implemented with Javascript. There are a few things I have difficulties with. The naming conventions, and dependency injections. ...
Melvin Idema's user avatar
1 vote
1 answer
618 views

I know this is a bit elementary, but I am highly uncomfortable writing Scheme code, and I want to make sure that what I'm doing is good practice. I know mutation is frowned upon in Scheme. I have no ...
Joseph Gutstadt's user avatar
1 vote
1 answer
174 views

I've recently started learning elixir, and the following is my attempt at fetching the local IP address of the system. It can definitely be improved further, but as this would be my first ever project ...
hjpotter92's user avatar
  • 8,941
1 vote
1 answer
951 views

I implemented tic-tac-toe in Haskell. I'm trying to incorporate suggestions from my last question (which mostly revolved around algorithmic logic) while trying something new - IO logic. What kind of ...
Scotty Jamison's user avatar
4 votes
2 answers
868 views

I'm trying to practice some functional techniques. I haven't worked much in Haskell, so any language-specific tips would be very appreciated, but what I care for even more are general tips towards my ...
Scotty Jamison's user avatar
2 votes
1 answer
647 views

I've been interested in making fully repeatable, reproducible game states. This led me into the world of DDD, and specifically, the concept of Aggregates + Event Sourcing (although that's not ...
Zymus's user avatar
  • 207
4 votes
3 answers
2k views

I have programmed a function to split strings, and it gives the expected output. I am looking forward to write better code and I was told here is a good place to start. Here's my program: ...
Majd's user avatar
  • 141
3 votes
1 answer
348 views

So reading about functional programming, applications to dynamic programming, and learning Scala. I figured I would try it out with a popular example, Pascal's Triangle, tests against known values ...
Martin Boros's user avatar
1 vote
1 answer
86 views

In my Motorola 6809 CPU emulator (written in C++14) I'm working on an abstraction to represent the wiring between emulated devices, such as the ports on a 6522 VIA, or the interrupt lines connecting a ...
Alnitak's user avatar
  • 441
3 votes
2 answers
255 views

I have a code that scrapes list of URL and appends dataframe as below: ...
PyNoob's user avatar
  • 199
5 votes
1 answer
329 views

I've created a two-player number guessing game in Haskell. My main objective was to practice dealing with "state" in a purely functional language (such as player scores, whose turn it is, ...
cgoates's user avatar
  • 185
2 votes
0 answers
96 views

I've created a Node.js/Express application that accepts personal data in a form on the front end with React (name, address, etc). It's purpose is to take a user's name, address, and some other info ...
Kyle Williams's user avatar
10 votes
3 answers
794 views

I wrote a 2048 game in JavaScript with an object-oriented paradigm. The game board is presented with a two-dimensional array and each tile holds an integer. Here is the implementation: ...
Joji's user avatar
  • 335
2 votes
0 answers
130 views

Below is my solution for the CTFP chapter 4 challenges which essentially involves composing partial functions (that don't have defined outputs for all possible inputs i.e. returning a Maybe). The ...
tangy's user avatar
  • 143
3 votes
0 answers
130 views

Application context I am working on a game I call "Apes and Snakes". So far the code only allows players to connect to a host using a room code and WebRTC. Players and the host send messages ...
Scoob's user avatar
  • 131
2 votes
1 answer
266 views

This is the challenge: You are given a sequence of N balls in 4 colors: red, green, yellow and blue. The sequence is full of colors if and only if all of the ...
Enlico's user avatar
  • 531
1 vote
1 answer
2k views

I have 4 CSV files that i need to process (filter out Part segment and then merge them) but the problem is that they do not fit in my memory. So I decided to: [open - filter - write out] each one of ...
amous's user avatar
  • 13
0 votes
1 answer
240 views

I have 2 dictionaries that I have to compare, if an element of one dictionary exists in the other dictionary, then add the element to an array but only one time... here the working code ...
manuelBetancurt's user avatar
3 votes
2 answers
681 views

...
Rabeea Rehman's user avatar
5 votes
2 answers
187 views

This program calculates the sum of all integers in the range \$[1, 1000)\$ which are multiples of either 3 or 5 or both. Inspired by x86-64 Assembly - Sum of multiples of 3 or 5 the other day, and ...
Edward's user avatar
  • 67.2k
2 votes
1 answer
1k views

I recently bumped into dry-python/returns, which seems like a very useful project. In the project description, the authors describe a snippet which can be written with their ...
oz123's user avatar
  • 507
2 votes
1 answer
2k views

I'm very new to haskell (I never used Monads, Functors and other things) and FP in general. I decided to write the simplest parser I possibly can with some expansion possibilities. (I have a general ...
somerandomdev49's user avatar
3 votes
2 answers
210 views

So I'm supposed to calculate variance based on this forumula through functional programming: $$\sigma^2 = \frac{\sum\limits_{i=0}^{n-1} (X -\mu)^2}{n-1}$$ This is the code that works: ...
Leon's user avatar
  • 133
1 vote
1 answer
93 views

Problem description. I have JSON which comes in bad shape: ...
Martin Kleiven's user avatar
2 votes
1 answer
142 views

Though many have done it the other way around, I have not seen such code in many places. And, to be honest, I don't know why this cluster of if-statements, ...
niamulbengali's user avatar
0 votes
1 answer
71 views

What are the pros and cons of each option, considering long-term implications (increasing the number of functions / parameters, other developers taking over, etc.)? Option 1: removes the need to pass <...
Teodor Ciuraru's user avatar
4 votes
3 answers
698 views

I tried to code the fizzbuzz program following the functional programming rules in javascript. Please check my code and give feedback. thank you. ...
Lokenath Karmakar's user avatar
1 vote
1 answer
154 views

Data Structure coming back from the server ...
FNMT8L9IN82's user avatar
3 votes
1 answer
274 views

This is a pretty simple working example using React-Redux to select a user from app.com/user/:userId and then fetch/display that user's info from a remote API Most ...
Coupcoup's user avatar
  • 1,086
4 votes
1 answer
67 views

I am writing code that runs a simulation in an interactive way. The building blocks are: runStep :: I -> State S O runWorld :: World m -> O -> StateT W m I ...
Cactus's user avatar
  • 212
3 votes
2 answers
163 views

I have a program for finding shortest distance/path and I got a correct answer but I am getting an issue i.e., "Function 'shortestPath' has a complexity of 9. Maximum allowed is 6." This is ...
L.Nyamagoud's user avatar
8 votes
3 answers
4k views

for clarity: moved here from stackoverflow after being pointed to Code Review being the better place for this question I love async/await and Promises since I got my hands on them. And I might be ...
gaugau's user avatar
  • 191
1 vote
1 answer
755 views

The idea is to represent a hand as a list of cards and create a frequency mapping, which can then be used to identify what rank of hand you have and arrange your hand in a way that allows the Ord type ...
L292092's user avatar
  • 409
2 votes
0 answers
365 views

Split: Write a function split that takes a delimiter value “c” and a list “iL”, and it ...
HalitrephesMaasi's user avatar
7 votes
3 answers
2k views

The following searches recursively for all the mark down files - i. ending with the extension .md - inside a folder. It then stores the text of the files in an ...
wyc's user avatar
  • 555
7 votes
4 answers
3k views

I am making an hours calculator app. It takes a start time, end time and time taken for lunch. For the start and end time it takes a four-digit hh:mm time. For example: 10:20. I have made a function ...
Ruari Douglas's user avatar
2 votes
1 answer
98 views

On StackOverflow I have asked a question a few minutes ago, but then by trying a bit more, I found the answer myself, and I'm posting the resulting working code here for review. What the code does, is ...
Enlico's user avatar
  • 531
3 votes
1 answer
295 views

Much like this question I'm attempting to write in C++ something which can resemble Haskell's (.) function as much as possible, which is basically Chapter 1's ...
Enlico's user avatar
  • 531
2 votes
1 answer
143 views

I solve projecteuler.net Problem 2 deferent way Generate number from 1 to range ex 100 and get the even number Get Fibonacci numbers from list Reduce array I have one problem with a large set of ...
NinjaDeveloper's user avatar
2 votes
2 answers
135 views

I'm trying to solve this problem on HackerRank, which basically requires the solution to read an input like this (comments are mine) ...
Enlico's user avatar
  • 531
3 votes
1 answer
65 views

This small piece of code shows the value of different fields of an array. I'm looking for a way to improve this nested ternary function. An if statement solution ...
Pankwood's user avatar
  • 173

1 2
3
4 5
21