= Mutual recursion
{wiki}
Two or more functions are mutually recursive when their definitions call one another in a cycle. Two <algebraic data types> can likewise be mutually recursive when constructors of each refer to the other. For alternating sequences `Zig a b` and `Zag b a`, descending one constructor exchanges the <type parameters>; a pair of mapping functions must exchange its arguments correspondingly. A mutually recursive fold may have two independent result types $r,s$: its handlers have types `a -> s -> r` and `b -> r -> s`, with empty results of types `r` and `s`. Equality of the two result types is not required by <type inference>.
Back to article page