Base: Implement ~~map~~, reduce, ~~filter~~ in formulas (lambda functions)

Use case or problem

While working with lists and objects in Bases, there is a lack of higher order functions. This will open up possibilities to work with complex dataset inside the frontmatter.

Proposed solution

Lambda functions as

(arg, arg2) => {statement1; statment2; return}

Higher order functions as

map(() => {}, [...])
map(() => {}, {...})

Related feature requests (optional)

MOD-EDIT: removed for not being related to this FR to avoid confusion

5 Likes

It would be great to have filter() function. Use case: I needed a way to reproduce this DV formula in bases:

            p.file.etags
            .filter((t) => t.startsWith("#project"))
            .map((item) => item.replace("#project/", ""))

I was able to reproduce the functionality of the dataview formula via join() and replace() but the Bases formula is much more convoluted and particular to my tag structure:

file.tags.join(", ").replace(/.*#project\//,"#project/").replace("#project/","").replace(/#source.*$/,"").replace(/#subject.*$/,"").replace(/#work.*$/,"").replace(/, $/,"")

map and filter will be implemented in 1.9.5. No ETAs. Renamed this FR for the future.

1 Like