mk: flatteno — nested list flattener
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 49s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 49s
Three conde clauses: nullo tree -> nullo flat; pairo tree -> recurse on
car & cdr, appendo their flattenings; otherwise tree must be a ground
non-list atom (nafc nullo + nafc pairo) and flat = (list tree).
Works on ground inputs of arbitrary nesting:
(run* q (flatteno (list 1 (list 2 3) (list (list 4) 5)) q))
-> ((1 2 3 4 5))
7 tests, 253/253 cumulative. Phase 4 list relations now complete.
This commit is contained in:
@@ -111,7 +111,11 @@ Key semantic mappings:
|
||||
- [x] `caro` / `cdro` / `conso` / `firsto` / `resto`
|
||||
- [x] `reverseo` `l` `r` — reverse of list. Forward is fast; backward is `run 1`-clean,
|
||||
`run*` diverges due to interleaved unbounded list search (canonical TRS issue).
|
||||
- [ ] `flatteno` `l` `f` — flatten nested lists (deferred — needs atom predicate)
|
||||
- [x] `flatteno` `l` `f` — flatten nested lists. Three conde clauses:
|
||||
empty → empty; pair → recurse on car & cdr + appendo; otherwise atom →
|
||||
`(== flat (list tree))`. Atom-ness is asserted via `nafc (nullo tree)
|
||||
+ nafc (pairo tree)` — both succeed only when tree is a ground non-list.
|
||||
Works on ground inputs.
|
||||
- [x] `permuteo` `l` `p` — permutation of list. Built on `inserto` (insert at any
|
||||
position) and recursive permutation of tail. All 6 perms of (1 2 3) generated
|
||||
forward; backward `run 1 q (permuteo q (a b c))` finds the input.
|
||||
@@ -169,6 +173,11 @@ _(none yet)_
|
||||
|
||||
_Newest first._
|
||||
|
||||
- **2026-05-08** — **flatteno**: nested-list flattener via conde + appendo.
|
||||
Atom-ness is detected via `nafc (nullo ...) + nafc (pairo ...)` so the
|
||||
third clause only fires when the input is a ground non-list. Works for
|
||||
`()` / atoms / flat lists / arbitrarily-nested lists. 7 new tests,
|
||||
253/253 cumulative. Phase 4 list relations all complete.
|
||||
- **2026-05-08** — **Laziness tests**: explicitly verifies the
|
||||
Zzz-on-conde-clauses + mk-mplus-swap-on-paused machinery: an
|
||||
infinitely-recursive relation truncated via `run 4 q (listo-aux q)`
|
||||
|
||||
Reference in New Issue
Block a user