37
votes
33
votes
How many arguments were passed?
JavaScript, 15 bytes
[].push.bind(0)
The Array.prototype.push function takes any number of arguments, adds them to its array, ...
26
votes
Church Booleans
Haskell, 50 - 6 = 44 bytes
-1 byte thanks to Khuldraeseth na'Barya, and -1 byte thanks to Christian Sievers.
...
25
votes
Implement an Over function
Haskell, 12 bytes
f?g=(.f).g.f
Try it online!
Haskell was made for this.
Let's unpack it:
...
20
votes
17
votes
17
votes
Accepted
How many arguments were passed?
Amstrad CPC Z80 binary call from BASIC, 1 byte, hex encoded
C9 : RET
(Also 2 and 5 byte versions, see below)
Upon entry to the call, the number of ...
14
votes
Accepted
Church Booleans
Binary Lambda Calculus, 13.875 12.875 bytes (103 bits)
Binary Lambda Calculus Language (BLC) by John Tromp is basically an efficient serialization format for lambda calculus. It is a great fit for ...
14
votes
Implement a zipwith function
Haskell, 22 bytes
(.zip).(.).map.uncurry
Try it online!
Not particularly interesting, just a reimplementation of zipWith ...
13
votes
Make a long type signature
Haskell with extensions, \$\ggg A(A(A(A(220,0),0),0),0)\$
Z::Z#Z#Z#Z#Z#Z#Z#Z#Z?Z
data a?b=Z|S(a?b)
type family m#n where Z#n=S n;S m#Z=m#S m;S m#S n=m#(S m#n)
Try ...
13
votes
Find a Fixed Point
APL (Dyalog), 2 bytes
⍣=
Try it online!
NB: I define O←⍣= in the the input section due to a bug in that derived monadic ...
12
votes
12
votes
12
votes
12
votes
Implement a zipwith function
Trivial builtin answers
Edit your answer into this post if it consists of a builtin which does the entire task by itself
HBL, 0.5 bytes
2
(Not implemented in the ...
Community wiki
12
votes
Implement an argwhere function
Python 3.8 (pre-release), 45 bytes
lambda l,F:[i for i,e in enumerate(l)if F(e)]
Try it online!
Looks like it won't get much shorter than this.
Explanation: keep ...
12
votes
Point-free JavaScript: write a function runner
Why I believe this is impossible (as stated)
There aren't very many JS builtins that call a function, and even fewer that call one with arbitrary arguments. The ones that I've found are the string ...
12
votes
Function with memories of its past life
JavaScript (V8), 21 bytes
f=s=>x=>f(x,print(s))
Try it online!
11
votes
Make a long type signature
Haskell, 9·2663552 − 3 (≈ 1.02·10199750)
A small (“small”) improvement over xnor’s 5⋅2262144 + 5. This is 99 bytes.
...
11
votes
11
votes
Tuple addition in pointfree
44 bytes
Got this from \x y -> (fst x + fst y, snd x + snd y)
(<*>).((,).).(.fst).(+).fst<*>(.snd).(+).snd
Try ...
11
votes
Implement an Over function
Factor, 16 bytes
[ bi@ rot call ]
Try it online!
Explanation:
It's a quotation (anonymous function) that takes a quotation with stack effect ...
11
votes
Simplify K combinatory logic expression
Perl 5 -p, 28 27 bytes
s/@(.K)(\1*K)\1*K/$2/&&redo
Try it online!
How it works
Each term in the \$K\$ calculus ...
11
votes
Curry tips for Haskell programmers
Use ++ in patterns
In Haskell we are used to handling lists with : as our pattern. Curry1 can do this but it can also use ...
10
votes
Find a Fixed Point
MATLAB, 41 bytes
function x=g(f,x);while f(x)-x;x=f(x);end
There is also this beauty that does not need function files. Unfortunately it is a little bit longer:
<...
10
votes
Church Booleans
Python 2, (-3?) 101 95 bytes
David Beazley eat your heart out!
-6 thanks to Chas Brown (moved the repeated : into the join text >.<)
...
10
votes
Point-free JavaScript: write a function runner
JavaScript (Node.js), 74 65 bytes
[].forEach.bind([{[Symbol.split]:(c=Map.call).bind(c)}],''.split)
Attempt This Online!
9
votes
Tuple addition in pointfree
44 bytes
-8 bytes thanks to Ørjan Johansen. -3 bytes thanks to Bruce Forte.
(.).flip(.)<*>(zipWith(+).)$mapM id[fst,snd]
Try it online!
Translates to:
<...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
functional-programming × 48code-golf × 41
haskell × 6
lambda-calculus × 6
combinatory-logic × 6
math × 5
array × 5
integer × 4
string × 3
tips × 3
number × 2
code-challenge × 2
decision-problem × 2
number-theory × 2
interpreter × 2
javascript × 2
atomic-code-golf × 2
programming-puzzle × 2
arithmetic × 1
restricted-source × 1
matrix × 1
parsing × 1
open-ended-function × 1
polynomials × 1
set-partitions × 1