Pbjson.dispatch: def of bendonnect-rpc@0.1.0.0 Import: import bendonnect-rpc@0.1.0.0/src/pbjson.bend as Pbjson Lines 399-406 of bendonnect-rpc@0.1.0.0/src/pbjson.bend: https://jend.leeeet.dev/read.txt?path=bendonnect-rpc@0.1.0.0/src/pbjson.bend&start_line=399&end_line=406 import Base # The number of the field whose accepted key equals k, or 0 for an unknown key. Typical use: # `M.set(m, Pj.dispatch(k, M.json_keys()), v)` where M.set destructures m, then matches on its U32 parameter. def dispatch(+k: String, table: List<&2, JKey>) -> U32: match table: case Nil{}: 0 case Con{JKey{+name, +num}, t}: Bool.pick(U32, String.eq(k, name), num, dispatch(k, t)) Uses (6): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Bool.pick https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=List https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=String https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=String.eq https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32 https://jend.leeeet.dev/definition.txt?path=bendonnect-rpc@0.1.0.0/src/pbjson.bend&name=JKey