Map.put.go: def of Base
Import: import Base
Lines 2732-2750 of Base/base.bend: https://jend.leeeet.dev/read.txt?path=Base/base.bend&start_line=2732&end_line=2750
import Base
# Map.put.go, Map.ins.go, Map.seek.go, Map.has.go, Map.get.go and
# Map.pop.go take the node they are in, whole, and the key's bit at it:
# the child they descend into is that node's field, a node rebuilt
def Map.put.go(-a: Quant, -V: Kind(a), node: Map, x: V, kb: String & Bool) -> Map:
match node kb:
case MNode{p, MTip{}, hi} Tuple{key, False{}}:
MNode{p, MLeaf{key, x}, hi}
case MNode{p, MLeaf{k, v}, hi} Tuple{key, False{}}:
MNode{p, MLeaf{k, x}, hi}
case MNode{p, MNode{+q, c, d}, hi} Tuple{key, False{}}:
MNode{p, Map.put.go(a, V, MNode{q, c, d}, x, Map.bit(key, q)), hi}
case MNode{p, lo, MTip{}} Tuple{key, True{}}:
MNode{p, lo, MLeaf{key, x}}
case MNode{p, lo, MLeaf{k, v}} Tuple{key, True{}}:
MNode{p, lo, MLeaf{k, x}}
case MNode{p, lo, MNode{+q, c, d}} Tuple{key, True{}}:
MNode{p, lo, Map.put.go(a, V, MNode{q, c, d}, x, Map.bit(key, q))}
case m _:
m
Uses (6):
https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Bool
https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Map
https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Map.bit
https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Pair
https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Sigma
https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=String