# Merge tensor trees

`(tree-merge tree...)` combines fixed tensor trees without changing any input.
Plist keys are united and ordered lexically; nested plists merge recursively.
Lists and vectors merge corresponding positions and must have matching types and
lengths. `nil` is the empty tree; no arguments returns `nil`.

```sh
sexpgpu probe --expr '(getf (tree-merge (list :a (full [] 2.0)) (list :b (full [] 5.0))) :b)' --max-elements 100
```

The result is `5.0`. Leaves are tensor values. Shared leaves remain shared. An
overlapping position must refer to the same tensor value; separate tensors with
equal numerical values still conflict. A merge never silently replaces a leaf.
Duplicate keys within an operand, incompatible structures and conflicting values
are `E-TREE-001`; the conflict names its path.

For complete [functional-call](https://sx.041.io/docs/functional-call.md) bindings, combine
`(parameters model)`, `(buffers model)` and `(frozen-parameters model)`. Query
those model trees inside a function or lambda after model paths are assigned; an
early model-value query is `E-FUNC-003`. Use [tree-map](https://sx.041.io/docs/tree-map.md) to
construct replacement values, then merge disjoint model-value subsets.

---

SexpGPU documentation. Every page: https://sx.041.io/llms.txt
