def OptState.map

bendtorch@1.3.0.0 · main.bend:69

import bendtorch@1.3.0.0/main.bend as Bendtorch
import Base

69# Two affine maps are supplied separately: each is called at most once. A packed tree is the same under any relabelling
70# of the parameters (Lin <-> Two), so it passes unchanged.
71def OptState.map(-P: Type, -Q: Type, st: OptState<P>, f: P -> Q, h: P -> Q) -> OptState<Q>:
72  match st:
73    case NoMom{}: NoMom{}
74    case OneMom{m}: OneMom{f(m)}
75    case TwoMom{m, v}: TwoMom{f(m), h(v)}
76    case Packed{t}: Packed{t}

Uses (1)

Used by (7)