Created
May 30, 2016 21:06
-
-
Save wolph/c9ce622fa4752781ff91a7579bc7c9ca to your computer and use it in GitHub Desktop.
Implementing the Quick sort algorithm using the Y Combinator
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
Y = lambda f: lambda *args: f(Y(f))(*args) | |
quicksort = Y(lambda f: | |
lambda x: ( | |
f([item for item in x if item < x[0]]) | |
+ [y for y in x if x[0] == y] | |
+ f([item for item in x if item > x[0]]) | |
) if x else []) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment