In formal methods of computer science, a paramorphism (from Greek παρά, meaning "close together") is an extension of the concept of catamorphism first introduced by Lambert Meertens[1] to deal with a form which “eats its argument and keeps it too”,[2] [3] as exemplified by the factorial function. Its categorical dual is the apomorphism.
It is a more convenient version of catamorphism in that it gives the combining step function immediate access not only to the result value recursively computed from each recursive subobject, but the original subobject itself as well.
Example Haskell implementation, for lists:
cata f b (a:as) = f a (cata f b as)cata _ b [] = b
para f b (a:as) = f a (as, para f b as)para _ b [] = b
ana u b = case u b of (a, b') -> a : ana u b'
apo u b = case u b of (a, Right b') -> a : apo u b' (a, Left as) -> a : as
Explanation on StackOverflow: https://stackoverflow.com/questions/13317242/what-are-paramorphisms, https://stackoverflow.com/questions/12767757/how-to-express-a-filter-that-relies-on-adjacent-elements-in-a-list-functionally/12768389#12768389, https://stackoverflow.com/questions/6941904/recursion-schemes-for-dummies
Blogs: http://fho.f12n.de/posts/2014-05-07-dont-fear-the-cat.html
Talks: https://www.youtube.com/watch?v=PK4SOaAGVfg