~/bend-docscommunity

recurrence.bend checks

raw source on the hub · import bend-kit-scheduler@0.1.0.0/recurrence.bend as Recurrence

Pure recurrence on arbitrary-precision Nat ticks: no wrapping or U32 conversion.

1 import
import Base

Types

type Missed source · line 4 · raw

Data

type Cadence source · line 8 · raw

Data

type Plan source · line 12 · raw

Data

Definitions

def replay source · line 15 · raw

@p:Plan -> List<&2, Nat>

def next source · line 20 · raw

@p:Plan -> Nat

def ticks source · line 26 · raw

@count:Nat -> @+previous:Nat -> @+period:Nat -> List<&2, Nat>

Generate only the bounded replay prefix, never the skipped remainder.

def limit source · line 34 · raw

@policy:Missed -> @overdue:Nat -> Nat

def rate source · line 43 · raw

@+previous:Nat -> @+completion:Nat -> @+period:Nat -> @policy:Missed -> Plan

A tick equal to completion is overdue. The already-completed previous tick is excluded. A positive period keeps all arithmetic exact, without overflow.

def positive source · line 48 · raw

@cadence:Cadence -> @+previous:Nat -> @+completion:Nat -> @+period:Nat -> Plan

def plan source · line 56 · raw

@previous:Nat -> @completion:Nat -> @period:Nat -> @cadence:Cadence -> Maybe<&2, Plan>

None is an explicit invalid-zero-period result, not a zero cadence.