Created
August 9, 2023 13:13
-
-
Save FCO/2853352c510a62ee866a1626fd968de3 to your computer and use it in GitHub Desktop.
better destructing?
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(@less), :Same(@same), :More(@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