def vadd

bendtorch@1.3.0.0 · spec.bend:19

import bendtorch@1.3.0.0/spec.bend as Spec
import Base

19# vector sum; the shorter vector counts as padded with zeros
20def vadd(xs: List<&2, Nat>, ys: List<&2, Nat>) -> List<&2, Nat>:
21  match xs ys:
22    case Nil{} _:
23      ys
24    case Con{x, xt} Nil{}:
25      Con{x, xt}
26    case Con{x, xt} Con{y, yt}:
27      Nat.add(x, y) <> vadd(xt, yt)

Uses (3)

Used by (9)