Don't you love it when one of the panel discussion members starts playing with their feet? https://youtu.be/DrF4dCC0daE?t=1451
haha this is me every time i have to sit still
Here is one of those questions where being self-taught is a disadvantage, but I'm sure many of you can help me to give this a name or point me into the right direction:
Say I have a tree, and the nodes can be resolved/expanded by a multimethod or similar. However, nodes could be arbitrarily expanded until they have their final shape and further expansion is a no-op.
I implemented this but it seems brutish: My base case is literally (= expanded resolved)
I don't have the right language for what I'm doing here I think and I might be complecting things on top of it all.
Another variation of this is macro expansion and the base case looks very similar to this
I will have a look at how it works and whether I'm doing something that's off. Is there some kind of general name for this approach?
computing a transitive closure is also like this. but not sure if there is a general name. maybe "expansion"?
I asked AI and it says: fixed-point iteration
The thing that irks me is that i do an extra expansion step and check if something changed.
where the fixed point is:
(defn fixed-point [f x]
(let [x' (f x)]
(if (= x x') x (recur f x'))))oh...
where did I encounter "fixed point" before? i need to check
maybe the fixed point combinator? http://en.wikipedia.org/wiki/Fixed-point_combinator
Yes! thank you
OK, now that I have a name for it I feel much better. Thank you
The thing that irks me is that i do an extra expansion step and check if something changed.It does feel like that, yeah. But it's not something you can circumvent unless each expansion step knows everything about all other expansion steps and can guarantee that its result will not be expandable by them. In that case, the result can be marked in some way, via metadata or some wrapper.
https://github.com/metosin/malli/#recursive-schemas
if you need a more robust validation than just an equality predicate, depending on the shape of your data, you could define a malli schema that's an :or with your base case and an expansion step applied to itself via a :ref.