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

I wrote a Connect Four game including a AI in Clojure and since I'm rather new to Clojure, some review would be highly appreciated. It can include everything, coding style, simplifications, etc. But ...
naeg's user avatar
  • 641
33 votes
6 answers
3k views

I was given a homework and I have 2 solutions: one that uses this and other one that doesn't. I tested both solutions on jsPerf but sometimes it says the version ...
Rahul Desai's user avatar
26 votes
3 answers
2k views

I am in the process of learning Clojure. I am fairly new to functional programming and would like to know if my code smells or if there are any performance implications with my approach. ...
Jeremy's user avatar
  • 539
22 votes
1 answer
4k views

I'm learning functional programming and their concept of Monads. I've found nothing more effective in learning than writing an implementation in a programming language I have experience with. I came ...
Mairbek Khadikov's user avatar
20 votes
1 answer
7k views

I have some Scala code that uses Internet to authorize a user. Therefore, it can throw Exceptions like IOException in the method. The original code was written in ...
Naetmul's user avatar
  • 303
19 votes
0 answers
220 views

Defines a simple module for timeoutable computations, with the ability to return arbitrary intermediary results on timeout or the final value otherwise. It also allows default return values. The ...
Lucian Carata's user avatar
18 votes
2 answers
6k views

I try to avoid using classes in Python as much as possible; if I don't plan on building on it, I don't build it in the first place. It helps me avoid Java-like classes like ...
yurisich's user avatar
  • 654
16 votes
0 answers
3k views

Problem Background MIDI is a serial representation of control signals to a sound generator. Typically, a noteOn message initiates the attack phase of a sound at a given pitch. The note will ...
user1441998's user avatar
15 votes
3 answers
114k views

I'm having fun with Java's Stream library and lambdas. The following code looks for persons within a list that have the same ID (which might indicate that something's wrong with the data) and prints ...
Matthias Braun's user avatar
15 votes
2 answers
2k views

I'm a C++ dev, and I've recently started working my way through Clean Code*. Whenever I encounter an example I think I could improve, I try to re-implement it in C++. On pp. 28-29 there is an example ...
SG_90's user avatar
  • 283
15 votes
1 answer
535 views

In order to exercise and learn Clojure, I decided to write a simple Minesweeper game from scratch. I'd consider myself as a Clojure novice and would be thankful if somebody could do a review or give ...
u6f6o's user avatar
  • 291
14 votes
2 answers
40k views

I'm trying to learn how to write functional code with Python and have found some tutorials online. Please note that I know Python is not a promoter for functional programming. I just want to try it ...
Lim H.'s user avatar
  • 305
14 votes
1 answer
3k views

I've implemented an identity function (well, actually a functor struct) in C++. The goal is that every occurrence of an ...
Zizheng Tai's user avatar
14 votes
1 answer
678 views

So I am trying to write, essentially from a blank slate, a program that plays Grand Chess. In short, it is a chess variant that is played with two extra pieces, on a 10x10 board, no castling, and ...
asibahi's user avatar
  • 937
13 votes
3 answers
10k views

C++ doesn't (yet) have a 'map' higher-order function, certainly not one which applies to a compile-time sequence of values like a tuple. We have std::transform, and ...
einpoklum's user avatar
  • 2,099
13 votes
2 answers
609 views

As a part of picking up concatenative programming, I decided to implement the common concatenative operations in PostScript. Here is my attempt at implementing some of the words in other concatenative ...
Rahul Gopinath's user avatar
13 votes
2 answers
756 views

I'm struggling to make my lambdas readable. I've seen various approaches. Below are three different examples that all do the same thing. Forgive the example: I suspect there are better actual ...
David Lavender's user avatar
13 votes
1 answer
483 views

MetaBrainz has an IRC channel called #metabrainz on which there's a bot called BrainzBot running. It provides utilities such as linking to JIRA issues or Github PRs ...
naiveai's user avatar
  • 166
13 votes
1 answer
2k views

I recently came across the classic algorithm for detecting cycles in a directed graph using recursive DFS. This implementation makes use of a stack to track nodes currently being visited and an extra ...
John Tyree's user avatar
12 votes
1 answer
2k views

I have all these functions that work together to create functionality on a page. Is the structure of these functions OK? Can I do anything to speed this up or make my code better? I'm not exactly ...
HandiworkNYC.com's user avatar
12 votes
2 answers
2k views

LINQ/FP style: Assert.IsTrue(new[] {1,2,3}.AnyPairSum(4)); Where: ...
Dmitry Nogin's user avatar
  • 6,131
12 votes
1 answer
990 views

I've written an Erlang implementation of the genetic algorithm for a "Hello World" program as described here. This is my first time writing any code in Erlang and also my first time writing code in a ...
gsgx's user avatar
  • 221
12 votes
1 answer
393 views

My code is attempting to implement FP in an efficient / readable manner into some of my video games. I realize this may be a bit subjective, but I feel there is enough merit / objectivity to be of ...
Fluidity's user avatar
  • 228
11 votes
4 answers
3k views

I have a JSON structure in the following example format: ...
fruitlessartery's user avatar
11 votes
2 answers
2k views

I'm learning Ruby 2.3 and I've tried to implement a function which performs the Luhn credit card verification algorithm on an input string, returning true if it ...
Aaron Christiansen's user avatar

1
2 3 4 5
21