Signed.wrap: def of bendtorch-core@0.1.0.0 Import: import bendtorch-core@0.1.0.0/src/tensor/signed.bend as Signed Lines 30-40 of bendtorch-core@0.1.0.0/src/tensor/signed.bend: https://jend.leeeet.dev/read.txt?path=bendtorch-core@0.1.0.0/src/tensor/signed.bend&start_line=30&end_line=40 import Base # PyTorch's wrap of a position among `limit` axes or elements (maybe_wrap_dim): # a position d in -limit..limit-1 becomes d + limit when d is negative and d # otherwise. A position outside that range stays outside it, at or past # `limit`, so the operation refuses it with its own check, code and order: # First{k} stays k, and an out-of-range Last{k} becomes `limit`. def wrap(+limit: U32, position: Position) -> U32: match position: case First{k}: k case Last{+k}: Bool.pick(U32, U32.is_lt(k, limit), U32.sub(U32.sub(limit, 1), k), limit) Uses (5): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Bool.pick https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32 https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.is_lt https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.sub https://jend.leeeet.dev/definition.txt?path=bendtorch-core@0.1.0.0/src/tensor/signed.bend&name=Position