Jump to content

Catamorphism: Difference between revisions

m
(→‎Excel LAMBDA: Added a second example)
Line 652:
# leaves the nesting depth unchanged for any other character
# 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 ⟶ 688:
),
depth
)
)
)
 
 
<lang lisp>bracketCount
=LAMBDA(a,
LAMBDA(c,
IF(ISNUMBER(FIND(c, "[]", 1)),
1 + a,
a
)
)
9,655

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.