how 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)