Catamorphism: Difference between revisions

Content added Content deleted
(→‎Excel LAMBDA: Added a second example)
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 count of bracket characters in a string, ignoring other characters, we could instead use FOLDLROW with an alternative binary operator like:

<lang lisp>bracketCount
=LAMBDA(a,
LAMBDA(c,
IF(ISNUMBER(FIND(c, "[]", 1)),
1 + a,
a
)
)
)</lisp>




Line 701: Line 688:
),
),
depth
depth
)
)
)


bracketCount
=LAMBDA(a,
LAMBDA(c,
IF(ISNUMBER(FIND(c, "[]", 1)),
1 + a,
a
)
)
)
)