-
Notifications
You must be signed in to change notification settings - Fork 176
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Special keyword to define mapping functions in expressions #1010
Comments
Correct me if I’m wrong, but we already have |
Some examples (assume we had Hypotenuse using numbers in a list:
Filter a list and only keep even numbers:
Single line pivot table: From a list of flights, to stats about outbound airports:
This can already be expressed with current syntax like so:
or
Similarly, it enables patterns like
(map each person to their name, then sort based on that) |
Makes sense. Thank you! |
Does it? I’m re-reading it now and I have no idea what I was thinking. 🙃 |
We've often struggled with how to let authors define inline functions in expressions, the concept of an arrow function seeming too out of reach for them.
This would be useful for many things:
Note that unlike Coda, we don't need things like
CountIf()
orAll()
since we can always do things likecount(foo > 2) > 1
, but they may be useful as sugar.Coda’s formula language solves this in an interesting way: They allow for a special
CurrentValue
keyword, which essentially represents the closest list item. In Mavo’s syntax, presumably this could be$value
or$current
?There is the problem of referring to outer currentvalues, which they solve with a special scoping function. I think that's suboptimal, I can think of two alternative ways to deal with it, which can be combined:
$outer
keyword.$outer.$value
would be the outer$value
, and things like$outer.$outer.$value
would also be possible$value
is the default parameter name, but you can provide your own name by using this syntax".The text was updated successfully, but these errors were encountered: