def wrap_each

bendtorch-core@0.1.0.0 · src/tensor/signed.bend:49

import bendtorch-core@0.1.0.0/src/tensor/signed.bend as Signed
import Base

49# Each coordinate wrapped among its own axis's extent. A coordinate past the
50# rank has no extent and is wrapped among 0: the read refuses the coordinate
51# count before any range.
52def wrap_each(dimensions: List<&2, U32>, positions: List<&2, Position>) -> List<&2, U32>:
53  match dimensions positions:
54    case Nil{} positions:
55      wrap_all(0, positions)
56    case extent <> rest Nil{}:
57      Nil{}
58    case extent <> rest head <> tail:
59      wrap(extent, head) <> wrap_each(rest, tail)

Uses (5)

Used by (7)