Catamorphism: Difference between revisions

Content added Content deleted
Line 652: Line 652:
# leaves the nesting depth unchanged for any other character
# leaves the nesting depth unchanged for any other character
# updates the accumulator no further if the nesting depth ever becomes negative.
# updates the accumulator no further if the nesting depth ever becomes negative.


or for a simple bracket count, we could just define a:

'''bracketCount(accumulator)(character)''' which:

# Increments the integer accumulator value on each "[" or "]"
# Leaves the accumulator unchanged for other characters.