ConstReduces an array to a single value from left to right.
const words = ['Ada', 'Lovelace'] as const;
const totalLength = Arr.foldl(words, (acc, word) => acc + word.length, 0);
const concat = Arr.foldl<string | number, string>(
(acc, value) => `${acc}-${value}`,
'items',
)(words);
assert.isTrue(totalLength === 11);
assert.isTrue(concat === 'items-Ada-Lovelace');
Reduces an array to a single value from left to right.
const words = ['Ada', 'Lovelace'] as const;
const totalLength = Arr.foldl(words, (acc, word) => acc + word.length, 0);
const concat = Arr.foldl<string | number, string>(
(acc, value) => `${acc}-${value}`,
'items',
)(words);
assert.isTrue(totalLength === 11);
assert.isTrue(concat === 'items-Ada-Lovelace');
Alias for
foldl.