Questions tagged [functional-programming]
This tag is for challenges related to the functional programming paradigm.
46
questions
18
votes
13
answers
2k
views
Emulate Jelly's tie-scan
The golfing language Jelly has a built-in ƭ called "tie", that cycles through a list of functions every time it's called. For example, ...
3
votes
0
answers
358
views
Implement the simplest functional programming language
The goal of this challenge is to compare how well different programming languages support functional programming, by seeing how much code it takes to implement BLC8, the simplest functional ...
12
votes
3
answers
1k
views
Point-free JavaScript: write a function runner
In this programming-puzzle, your goal is to write the following function in JavaScript, using (essentially) point-free (tacit) programming:
(f) => void(f())
...
10
votes
5
answers
549
views
Write a variadic fixed point combinator
A fixed-point combinator is a higher order function \$\mathrm{fix}\$ that returns the fixed point of its argument function. If the function \$f\$ has one or more fixed points, then $$\mathrm{fix} f=f(\...
27
votes
18
answers
2k
views
Implement the flip-floperator
Ruby has a strange operator, .., called flip-flop (not to be confused with the range operator, which looks the same). Used in a loop, flip-flop takes two conditions ...
16
votes
14
answers
2k
views
Persistence of a number
The persistence of a number \$x = d_1d_2d_3...d_n\$, with \$d_1 \ne 0\$, under some function \$f : \mathbb N_0 \times \mathbb N_0 \to \mathbb N_0\$ is defined as the number of applications of \$f\$ to ...
11
votes
2
answers
871
views
Curry tips for Haskell programmers
Curry is the Language of the Month this month and some users are starting to get into it, so let's get some tips together.
Haskell and Curry are similar in a lot of ways and a lot of tips for Haskell ...
20
votes
37
answers
2k
views
Implement an argwhere function
The \$\text{argwhere}\$ function takes a list of values and a predicate/boolean function as arguments and returns a list of indices where the predicate function returns true in the input list. For ...
15
votes
8
answers
1k
views
Simplify K projections
Background
K functions have a feature called projection, which is essentially partial application of values to a function. The syntax for projections is a natural extension of the regular function ...
7
votes
4
answers
278
views
Ordered, linear, affine, or relevant?
Background
Supplementary reading 1, Supplementary reading 2
Linear lambda calculus is a limited form of lambda calculus, where every bound variable must be used exactly once. For example, ...
19
votes
14
answers
1k
views
Unfold a list using a function
Task
Haskell's and Scala's standard libraries have an unfold function that builds a list from an initial state s and a function <...
17
votes
2
answers
972
views
We all know how to SKI, but can you BCKW?
Background
Lambda calculus is a model of computation using lambda terms.
A variable \$x\$ is a lambda term.
If \$E\$ is a lambda term, the lambda abstraction \$\lambda x. E\$ is a lambda term.
If \$...
21
votes
45
answers
3k
views
Implement a cleave function
Think of cleave as the conceptual inverse of map. If map applies a function to each number in a list...
map([1, 2, 3], x -> x * 5) -> ...
9
votes
3
answers
409
views
Implement Fix2 combinator
Background
The fixed-point combinator \$\textsf{fix}\$ is a higher-order function that computes the fixed point of the given function.
$$\textsf{fix}\ f = f\ (\textsf{fix}\ f)$$
In terms of ...
14
votes
8
answers
856
views
Simplify K combinatory logic expression
Background
Combinatory logic is a system where a term is written using a finite set of combinators and function application between terms, and reduction rules are defined for each combinator. The well-...