def HMap.join

bend-kit-collections@0.1.4.1 · hmap.bend:156

import bend-kit-collections@0.1.4.1/hmap.bend as Hmap
import Base

156# Rebuilds a branch; one with two empty subtries becomes HNil.
157def HMap.join(-K: Data, -V: Data, lo: HMap<K, V>, hi: HMap<K, V>) -> HMap<K, V>:
158  match lo:
159    case HNil{}:
160      match hi:
161        case HNil{}:
162          HNil{}
163        case HLeaf{h, es}:
164          HBranch{HNil{}, HLeaf{h, es}}
165        case HBranch{a, b}:
166          HBranch{HNil{}, HBranch{a, b}}
167    case HLeaf{h, es}:
168      HBranch{HLeaf{h, es}, hi}
169    case HBranch{a, b}:
170      HBranch{HBranch{a, b}, hi}

Uses (1)

Used by (5)