Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,15 @@
|
|||
package require Tcl 8.5
|
||||
|
||||
proc quicksort {m} {
|
||||
if {[llength $m] <= 1} {
|
||||
return $m
|
||||
}
|
||||
set pivot [lindex $m 0]
|
||||
set less [set equal [set greater [list]]]
|
||||
foreach x $m {
|
||||
lappend [expr {$x < $pivot ? "less" : $x > $pivot ? "greater" : "equal"}] $x
|
||||
}
|
||||
return [concat [quicksort $less] $equal [quicksort $greater]]
|
||||
}
|
||||
|
||||
puts [quicksort {8 6 4 2 1 3 5 7 9}] ;# => 1 2 3 4 5 6 7 8 9
|
||||
Loading…
Add table
Add a link
Reference in a new issue