Skip to content

Instantly share code, notes, and snippets.

@FCO
Created August 9, 2023 13:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FCO/2853352c510a62ee866a1626fd968de3 to your computer and use it in GitHub Desktop.
Save FCO/2853352c510a62ee866a1626fd968de3 to your computer and use it in GitHub Desktop.
better destructing?
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