Forum Discussion
JRahm
Admin
May 08, 2009Optimize This! iRule Contest
Hey there iRulers!
I'm opening up a little optimization contest. For background on this iRule, check out Lori's blog (Click here) and my follow up (Click here)
I only optimized the variable...
Nat_Thirasuttakorn
Employee
May 09, 2009how about this one...
when RULE_INIT {
set static::max 10
set static::f(0) { $num }
set i 1
while { $i < $static::max } {
eval "set static::f($i) { $static::f([expr $i - 1]) + int(rand() * \$d) }"
incr i
}
}
when HTTP_REQUEST timing on {
if { [HTTP::uri] starts_with "/roll"} {
set num [URI::query [HTTP::uri] "num"]
set d [URI::query [HTTP::uri] "d"]
HTTP::respond 200 content "$num d $d = [expr $static::f($num)]"
}
}
* I guess we can remove round() function since its input is arealdy integer.. (correct me if I am wrong)
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects
