Closed posita closed 2 years ago
AnyDice has a pretty compact syntax for this, partially because it manages recursion base cases implicitly (via its global maximum recursion depth
parameter).
function: doit six VAL:n {
if VAL = 6 { result: [doit four d4] }
else { result: VAL }
}
function: doit four VAL:n {
if VAL = 1 { result: VAL + [doit six d6] }
else { result: VAL }
}
output [doit six d6]
I wonder if we need to tackle this at the recursion management level rather than continue to fiddle with the separation between expand and coalesce. 🤔
Here's a contrived example for which
dyce
doesn't provide a convenient interface:Maybe the ability for expand to return an optional coalesce override would work?