### RRand.tcl 3.3.0 pQFrdM8L
#REQUIREMENTS
# PBinScr.tcl fMrtKqyq
#LICENSE
# Copyright © 2013 Alberto Dietze "DoctorD90"
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Full GPLv3 Text: http://www.gnu.org/licenses/gpl.txt
#PATERNITY
#Coder: DoctorD90
#Network: irc.OnlineGamesNet.net
#Chan: #eHito
#Mail: [email protected]
#
#Thanks to guys on #egghelp on irc.freenode.net
#PURPOSE
# With this proc, it'll be simplier randomize
#a number in an interval between 2 of them
# of your choice.
#USAGE
#set var [rrand a b]
# a InferiorLimit
# b SuperiorLimit
### DON'T EDIT ANYTHING BELOW ###
proc rrand {inf {sup {}}} {
if {![string is integer -strict $inf]} {
error "Inferior Limit is not a number"
}
if {![string length $sup]} {
return [rand $inf]
}
if {![string is integer -strict $sup]} {
error "Superior Limit is not a number"
}
if {$inf == $sup} {
return $inf
}
if {$inf > $sup} {
set infb $inf
set inf $sup
set sup $infb
}
set gap [expr {$sup - $inf + 1}]
return [expr {int(rand() * $gap) + $inf}]
}
###
putlog "RRand.tcl LOADED"
Comments
0 B
|👍
/👎
0 B
|👍
/👎
0 B
|👍
/👎