Skip to main content
53 votes

Arbitrary-length currying

JavaScript (ES6), 18 bytes f=n=>m=>m?f(m+n):n Pass a falsy value to retrieve the sum. Zeros could be allowed for a cost of 2 bytes. Try it online ...
Neil's user avatar
  • 172k
37 votes

How many arguments were passed?

Java (JDK 10), 11 bytes a->a.length Try it online!
Olivier Grégoire's user avatar
32 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, ...
apsillers's user avatar
  • 3,742
29 votes

Implement Takewhile

Mathematica, 18 bytes #~TakeWhile~EvenQ& Another glorious built-in that is beaten by a factor of 3 by golfing languages without the built-in...
Martin Ender's user avatar
28 votes

Implement Takewhile

Haskell, 13 bytes fst.span even span splits the input list into a pair of lists just before the first element where the ...
nimi's user avatar
  • 35.9k
26 votes

Church Booleans

Haskell, 50 - 6 = 44 bytes -1 byte thanks to Khuldraeseth na'Barya, and -1 byte thanks to Christian Sievers. ...
Nitrodon's user avatar
  • 10.8k
25 votes

Implement Takewhile

MATL, 6 bytes toYs~) Try it online! Explanation ...
Luis Mendo's user avatar
  • 105k
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: ...
xnor's user avatar
  • 145k
22 votes

Arbitrary-length currying

Haskell (GHC), 118 bytes This is 98 bytes for the code and 20 bytes for the GHC compiler flag -XFlexibleInstances, which enables a type system extension. ...
Zgarb's user avatar
  • 42.7k
20 votes

How many arguments were passed?

JavaScript (ES6), 16 bytes (...a)=>a.length ...
tsh's user avatar
  • 34.9k
17 votes

Arbitrary-length currying

Python 2, 42 41 36 bytes This solution will never have an overflow, since Python supports arbitrary-precision integers. Zero is the "special value". ...
mbomb007's user avatar
  • 23.4k
17 votes

How many arguments were passed?

Python 3, 15 bytes lambda*a:len(a) Try it online!
Leaky Nun's user avatar
  • 49.8k
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 ...
CJ Dennis's user avatar
  • 4,266
14 votes

Implement Takewhile

Hexagony, 19 2.}<@>%?<{>$"/\M!8; Readable: 2 . } < @ > % ? < { > $ " / \ M ! 8 ; Try it ...
FryAmTheEggman's user avatar
14 votes

Arbitrary-length currying

Mathematica, 25 bytes f[x_]@y_=f[x+y] f[x_][]=x Try it online! (Using Mathics.) It's possible to do three bytes less by porting the JavaScript answer, but I ...
Martin Ender's user avatar
14 votes

Arbitrary-length currying

C, 62 58 bytes, borderline competing Saved 4 bytes thanks to Kevin! (Still not removing typedef because it's something needed in order to be called.) ...
Conor O'Brien's user avatar
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 ...
Pavel Potoček's user avatar
14 votes

Implement a zipwith function

Haskell, 22 bytes (.zip).(.).map.uncurry Try it online! Not particularly interesting, just a reimplementation of zipWith ...
orthocresol's user avatar
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 ...
dfeuer's user avatar
  • 1,167
13 votes

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

Husk Husk is a pure functional golfing language created by me and Leo and inspired by Haskell. It combines a rigid type system, type inference and extensive overloading. Functions are first class ...
Zgarb's user avatar
  • 42.7k
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 ...
H.PWiz's user avatar
  • 11.6k
12 votes

How many arguments were passed?

Zsh, 7 5 bytes <<<$# Try it online!
Pavel's user avatar
  • 9,377
12 votes

Make me some curry

JavaScript (ES6), 35 bytes f=g=>g.length<2?g:a=>f(g.bind(f,a))
Neil's user avatar
  • 172k
12 votes

Make me some curry

Idris, 204 bytes ...
lynn's user avatar
  • 68.8k
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 ...
emanresu A's user avatar
  • 38.8k
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. ...
Anders Kaseorg's user avatar
11 votes

Implement Takewhile

ed, 13 /[13579]$/,$d Because real programmers use The Standard Text Editor. Takes input as one integer on each line; outputs in the same format. This simply ...
Doorknob's user avatar
  • 71.5k
11 votes

Find a Fixed Point

Haskell, 17 bytes until=<<((==)=<<) Try it online!
nimi's user avatar
  • 35.9k

Only top scored, non community-wiki answers of a minimum length are eligible