Created
April 20, 2021 11:52
-
-
Save hyphenrf/1c74cd6de1b4545971416afe6b48f63f to your computer and use it in GitHub Desktop.
Does this make you angry?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import functools | |
c = lambda f: lambda g: lambda x: f (g (x)) | |
add = lambda x: lambda y: x + y | |
const = lambda x: lambda y: x | |
uncurry = lambda f: lambda x, y: f (x) (y) | |
succ = add (1) | |
fold = lambda f: lambda z: lambda xs: functools.reduce(uncurry(f), xs, z) | |
len = fold (c (const) (succ)) (0) | |
print (len (range (100))) # stdout: 100 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment