Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
967ad364
Commit
967ad364
authored
Jul 13, 2018
by
antirez
Browse files
Test: add lshuffle in the Tcl utility functions set.
parent
d6efd5fc
Changes
1
Hide whitespace changes
Inline
Side-by-side
tests/support/util.tcl
View file @
967ad364
...
...
@@ -375,3 +375,17 @@ proc start_write_load {host port seconds} {
proc stop_write_load
{
handle
}
{
catch
{
exec /bin/kill -9 $handle
}
}
# Shuffle a list. From Tcl wiki. Originally from Steve Cohen that improved
# other versions. Code should be under public domain.
proc lshuffle
{
list
}
{
set n
[
llength $list
]
while
{
$n
>0
}
{
set j
[
expr
{
int
(
rand
()
*$n
)}]
lappend slist
[
lindex $list $j
]
incr n -1
set temp
[
lindex $list $n
]
set list
[
lreplace
[
K $list
[
set list
{}]]
$j $j $temp
]
}
return $slist
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment