Find … Match block: find the first item that passes a test #255

Closed
opened 2026-09-28 11:33:19 +02:00 by meleki · 1 comment
Owner

A classic getter with a predicate needs For each + break today. The item goes out to the right, the test hangs below, and its result has to wire back to the left into break. It works but the wires cross the node.

Goal

A block of two nodes, like Houdini's for-each blocks:

  • Find: inputs exec, list; outputs item, index.
  • Match: input match (bool); outputs found, item, index, not found.
  • Any data graph between them is the test, so everything flows left to right.
  • Inserting Find brings its Match along in one undo step.
  • The editor draws a frame behind the block.

Decision

Which Match belongs to which Find follows from the wiring only (the Match whose test reads that Find's item/index). Nothing is stored, so copy, paste and undo need no own code. Unpaired or ambiguous nodes get a warning.

Follow-up in the same round: splitting struct outputs into field pins (separate issue).

A classic getter with a predicate needs `For each` + `break` today. The item goes out to the right, the test hangs below, and its result has to wire back to the left into `break`. It works but the wires cross the node. ## Goal A block of two nodes, like Houdini's for-each blocks: - **`Find`**: inputs `exec`, `list`; outputs `item`, `index`. - **`Match`**: input `match` (bool); outputs `found`, `item`, `index`, `not found`. - Any data graph between them is the test, so everything flows left to right. - Inserting `Find` brings its `Match` along in one undo step. - The editor draws a frame behind the block. ## Decision Which `Match` belongs to which `Find` follows from the wiring only (the `Match` whose test reads that `Find`'s `item`/`index`). Nothing is stored, so copy, paste and undo need no own code. Unpaired or ambiguous nodes get a warning. Follow-up in the same round: splitting struct outputs into field pins (separate issue).
Author
Owner

Done in 2aaca01, wiki: Behaviors (Find … Match).

  • Find (exec, list → item, index) and Match (match → found, item, index, not found). The first true match continues at found; no hit or an empty list continues at not found with an empty item and index -1.
  • The pair follows from the wiring only. Unpaired or ambiguous nodes show a warning; at run time the flow ends at an unpaired Find and the console says so.
  • Inserting Find places its Match 480 px to the right, one undo step.
  • A quiet frame is drawn behind Find, Match and the test nodes; literals from outside stay outside.
  • The test consists of data nodes only, like break of For each.

Tests: ./check.sh 184 files, 2694 tests, CHECK EXIT 0. e2e 1-6: 272 checks passed. New find-match.test.ts (12 tests), e2e 6z-v (3 checks, real mouse). Counter-checks in unit and browser all fail as expected.

Done in 2aaca01, wiki: *Behaviors* (Find … Match). - `Find` (exec, list → item, index) and `Match` (match → found, item, index, not found). The first true `match` continues at `found`; no hit or an empty list continues at `not found` with an empty item and index -1. - The pair follows from the wiring only. Unpaired or ambiguous nodes show a warning; at run time the flow ends at an unpaired `Find` and the console says so. - Inserting `Find` places its `Match` 480 px to the right, one undo step. - A quiet frame is drawn behind `Find`, `Match` and the test nodes; literals from outside stay outside. - The test consists of data nodes only, like `break` of `For each`. Tests: `./check.sh` 184 files, 2694 tests, CHECK EXIT 0. e2e 1-6: 272 checks passed. New `find-match.test.ts` (12 tests), e2e 6z-v (3 checks, real mouse). Counter-checks in unit and browser all fail as expected.
admin added this to the Development project 2026-09-28 21:22:16 +02:00
admin moved this to Done in Development on 2026-09-28 21:22:23 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: meleki/feuerwerk#255