def swap2

bendonnect-rpc@0.1.0.0 · src/b64.bend:22

import bendonnect-rpc@0.1.0.0/src/b64.bend as B64
import Base

22# Maps char a1 to b1 and a2 to b2, leaving other chars alone.
23def swap2(s: String, +a1: U32, +b1: U32, +a2: U32, +b2: U32) -> String:
24  match s:
25    case SNil{}:
26      SNil{}
27    case SCon{Chr{+c}, t}:
28      SCon{Chr{Bool.pick(U32, U32.is_eq(c, a1), b1, Bool.pick(U32, U32.is_eq(c, a2), b2, c))}, swap2(t, a1, b1, a2, b2)}

Uses (5)

Used by (2)