Created
August 9, 2023 13:10
-
-
Save FCO/45e87c3cff87476174ee6ddd25260043 to your computer and use it in GitHub Desktop.
destructing classify
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
multi quicksort([]) { Empty } | |
multi quicksort([$pivot, *@rest]) { | |
my (:@Less, :@Same, :@More) := @rest.classify(* cmp $pivot); | |
[ |quicksort(@Less), $pivot, |@Same, |quicksort(@More) ] | |
} | |
say quicksort [7, 2, 1, 8, 1, 9, 3] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment