Perform recursion and aggregation with m/cata
epsilonThe m/cata operator allows patterns to call themselves, enabling recursive processing and accumulation of results. This is useful for reducing a nested structure into a single value or transforming nested maps/sequences.
;; Example: Reducing a list to a single value via recursion
(m/rewrite [() '(1 2 3)]
[?current (?head & ?tail)]
(m/cata [(?head & ?current) ?tail])
[?current ()]
?current)
;; => (3 2 1)