diff options
Diffstat (limited to 'js/util.js')
| -rw-r--r-- | js/util.js | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/js/util.js b/js/util.js new file mode 100644 index 0000000..5828a91 --- /dev/null +++ b/js/util.js @@ -0,0 +1,5 @@ + +function avg(a,b,n){ return (a*(n-1) + b)/n; } +function rand(n) { return ~~(Math.random()*n); } +function randrange(a,b){ return (b-a)+rand(a); } +function choice(a) { return a[rand(a.length)]; } |
