m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarcin Chrzanowski <marcin.j.chrzanowski@gmail.com>2017-07-14 23:46:16 -0400
committerMarcin Chrzanowski <marcin.j.chrzanowski@gmail.com>2017-07-14 23:46:16 -0400
commit31307362fac9a6d75a373463495aa688cfbc3cd1 (patch)
tree407227eea9ed4d967b5547941c14d264e7028204 /src
parentde517d06737f77a0cfc818c159b388b4e0c4d6b1 (diff)
Define and use the pool function
Diffstat (limited to 'src')
-rw-r--r--src/dice.js10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/dice.js b/src/dice.js
index c8a2572..5edc892 100644
--- a/src/dice.js
+++ b/src/dice.js
@@ -1,7 +1,11 @@
const constant = n => () => [n]
+const pool = (die) => {
+ return die()
+}
+
const roll = (die) => {
- return die().reduce((a, b) => (a + b))
+ return pool(die).reduce((a, b) => (a + b))
}
const d = (number, sides) => {
@@ -37,8 +41,10 @@ const subtract = (die1, die2) => {
}
}
+exports.pool = pool
+exports.roll = roll
exports.constant = constant
exports.d = d
exports.add = add
exports.subtract = subtract
-exports.roll = roll
+exports.negative = negative