ludic/docs/language/dict/dict-set.md
Orkuncakilkaya 539f258d92
All checks were successful
bootstrap / cfree-fixpoint (push) Successful in 20s
ci / build-and-test (push) Successful in 1m29s
commit-lint / conventional-commits (push) Successful in 6s
docs / build-and-deploy (push) Successful in 21s
feat(types): Dict + Set string-keyed containers (#54)
Types phase 4 — containers. A splice-on-demand open-addressing hash table
(runtime/native/dict.ludic, FNV-1a, linear probing, tombstones, grow at 0.7)
behind two namespaces:

- Dict.* — string -> int map: new/set/get/get_or/has/remove/size/clear/keys.
  Resource counts, id/name registries. O(1) average vs a linear list scan.
- Set.* — set of strings: new/add/has/remove/size/clear/members. Tags,
  unlocked achievements, visited tiles. Shares the same table.

Values are int (also an entity handle / small id); Value.* covers richer
maps. [T; N] inline fixed arrays remain future work — typed buffers and []T
slices already cover heap-backed arrays.

Wired: parser splice trigger (g_uses_dict), emit_call dispatch, reseeded seed,
a self-asserting example (examples/library/containers.ludic + feat_case), and
per-symbol docs + inventory. All suites green incl. golden renders byte-
identical and the bootstrap fixpoint.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-08-31 18:51:42 +03:00

22 lines
421 B
Markdown

---
id: dict-set
name: Dict.set
category: dict
kind: namespace-method
tokens: Dict.set
sig: Dict.set(d, key, value)
tip: Insert or update a key.
order: 1
ns: Dict
member: set
---
Associates <code>value</code> with <code>key</code>, inserting it or overwriting the previous value. The table grows automatically as it fills.
```ludic
program Demo {
handler Step phase Update {
Dict.set(bank, "gold", 100)
}
}
```