-
Notifications
You must be signed in to change notification settings - Fork 54
Accumulate (set of) entities within a function call #434
Description
Problem to Solve
Accumulate entities within a function call
"Accumulate entities within a function call" is really the whole idea, but here's a motivating illustration. Please inform me if there is already a way to do this!
Consider a relation 'contains' from 'container' to 'content'.
Suppose we need the function 'first-containerward-nonlinearity'
which takes a node and returns a node,
where a 'terminus' satisfies any of these conditions:
- being a root (does not play 'content')
- being a fork (plays 'content' more than once)
- being one of the nodes our containerward traversal already saw
So for instance, given this data:
#+begin_example
a contains b
b contains c
c contains a <-- a again!
a contains d
d contains e
#+end_example
calling first-containerward-nonlinearity' on 'e' yields 'a',
finding it by traversing containerward
until hitting 'a' the second time.
To define this function, I seem to need to be able to accumulate during its execution. Do I not? If I do, is that expressible?
Current Workaround
I can make individual containerward calls from Rust and accumulate there. It works but it's slow.
Proposed Solution
I think this requires syntax for accumulating entities within a function call. If I'm wrong and there's another way I'd love to know.
An insufficient solution
Claude suggested preempting the response "use a depth counter". That would not work because the depth to the cycle entry point is unpredictable.