Skip to main content

Questions tagged [functional-programming]

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

0 votes
4 answers
294 views

Implement a Monad

A monad is a type that wraps another type, that represents the available operations on the wrapped type. Monads have the following associated operations, where M is ...
bigyihsuan's user avatar
10 votes
14 answers
2k views

Function with memories of its past life

Task I need a function that accept string and return a function f1. That f1 function should also accept string and return a <...
talex's user avatar
  • 927
24 votes
19 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, ...
emanresu A's user avatar
  • 45.1k
3 votes
1 answer
524 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 ...
John Tromp's user avatar
  • 1,431
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()) ...
rydwolf's user avatar
  • 19.1k
10 votes
6 answers
689 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(\...
Legendary Wizard's user avatar
28 votes
19 answers
3k 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 ...
Jordan's user avatar
  • 11.4k
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 ...
caird coinheringaahin g's user avatar
11 votes
2 answers
896 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 ...
Wheat Wizard's user avatar
  • 101k
24 votes
42 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 ...
chunes's user avatar
  • 27.2k
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 ...
Bubbler's user avatar
  • 78.8k
7 votes
4 answers
294 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, ...
Bubbler's user avatar
  • 78.8k
19 votes
16 answers
2k 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 <...
user's user avatar
  • 379
17 votes
2 answers
1k 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 \$...
Bubbler's user avatar
  • 78.8k
23 votes
46 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) -> ...
chunes's user avatar
  • 27.2k

15 30 50 per page