Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [functional-programming]

This tag is for challenges related to the functional programming paradigm.

34
votes
64answers
5k views

P Pr Pre Pref Prefi Prefix Prefixe Prefixes

Given some finite list, return a list of all its prefixes, including an empty list, in ascending order of their length. (Basically implementing the Haskell function ...
19
votes
13answers
1k views

Dirichlet Convolution

The Dirichlet convolution is a special kind of convolution that appears as a very useful tool in number theory. It operates on the set of arithmetic functions. Challenge Given two arithmetic ...
0
votes
2answers
169 views

Map an array of functions to their return values in point-free style

Introduction I have some JavaScript code that uses Array.prototype.map to map an array of functions fns to their return values: ...
21
votes
13answers
2k views

Make me some curry

Having a function f that takes arguments x1, x2, …, xn                         &...
14
votes
18answers
902 views

Find relevant digit groupings

Recently, my reputation was 25,121. I noticed that each digit grouping (i.e. the numbers separated by commas) was a perfect square. Your challenge is, given a non-...
23
votes
27answers
2k views

Generalized matrix trace

Inspiration. Given (by any means): A two-argument (or single argument consisting of a two-element list) black box function, f: ℤ+ × ℤ+ → ℤ+ (input and output are ...
15
votes
4answers
561 views

Tuple addition in pointfree

What is the shortest way we can express the function f(a,b)(c,d)=(a+c,b+d) in point-free notation? pointfree.io gives us ...
24
votes
25answers
2k views

Find a Fixed Point

Given an integer x1 and some black box function f: ℤ → ℤ find a fixed point of f in the ...
13
votes
2answers
615 views

Are there any functional programming languages designed for code-golfing?

Are there any functional programming languages designed for code golfing? I know that golfscript and CJam fulfill the same category for stack based, but I couldn't find a functional code golfing ...
52
votes
38answers
4k views

Arbitrary-length currying

Write a function, f, that takes in a positive integer and returns a function. The new function returned should be identical to f...
20
votes
1answer
586 views

Convert λ-expressions to SK-expressions

The λ-calculus, or lambda calculus, is a logical system based on anonymous functions. For example, this a λ-expression: λf.(λx.xx)(λx.f(xx)) However, for the ...
19
votes
10answers
1k views

Make a long type signature

Challenge Find an expression, at most 100 bytes long, with the longest type signature. Rules Any statically typed language with type inference is allowed The type must be non-ambiguous, but ...
0
votes
3answers
151 views

Define map in the fewest tokens [closed]

map is a very basic yet important function in functional programming. All FP programming languages have it built-in but it is always fun to see how shortly you can ...
21
votes
9answers
859 views

Implement functional programming paradigms

Your company is just getting started on a project, and for the first time you decided to go use a functional programming code-style. However your boss is really diffident and doesn't want to use built-...
7
votes
6answers
698 views

Most concise way to fold tree structures

Background (F#) Let there be trees: type Tree<'T> = Node of 'T * Tree<'T> list Now lets fold them nicely with a function called... ...
-1
votes
1answer
161 views

Compare array of decimal sum of Integers and exact fractional part

Develop a program which takes two arrays of decimal numbers, and compare the sum of whole numbers only and the decimal part. If the sums of the whole numbers are the same, and the decimal parts of ...
6
votes
5answers
295 views

Write biSp in point-free form using as few terms as possible

The Haskell function biSp has type signature ...
18
votes
3answers
2k views

Shortest a -> b -> (a -> b) function in Haskell

I got the following question at a test: Write a function f with the following type a -> b -> (a -> b). ...
6
votes
11answers
416 views

Write a function that reduces compositions of linear operators

You are given two functions g(x) and h(x), each of which takes an integer x and returns the ...
9
votes
5answers
414 views

Golfed fixed point combinator

Write a fixed point combinator in as few characters as possible, in the language of your choice. free form (i.e., whatever's shortest): whole program, actual function, code snippet you may not use ...