Last active
November 14, 2023 04:57
-
-
Save narskidan/fd746a6c1a443fd7244d7bfb957a9260 to your computer and use it in GitHub Desktop.
Quicksort in Hoon!
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
|= l=(list @ud) | |
^- (list @ud) | |
?: =(0 (lent l)) | |
~ | |
=/ pivot (snag 0 l) | |
=/ rest (slag 1 l) | |
=/ less (skim rest |=(a=@ (lte a pivot))) | |
=/ more (skim rest |=(a=@ (gth a pivot))) | |
:(weld $(l less) ~[pivot] $(l more)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Quick (ha) reference implementation I wrote in Python of how the Hoon code "should" work: