-
Notifications
You must be signed in to change notification settings - Fork 35
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
Object and advanced array comprehensions #439
Comments
Spreads could also apply to object results as well. |
Another application would be the ability to flatten the results of nested array := for sublist of list
...for item of sublist
item ** 2
---
const array = (function(){const results = []
for (const sublist of list) {
for (const item of sublist) {
results.push(item ** 2)
}
}
})() This gives us a very flexible equivalent of Janet's |
+1 on the object comprehensions: looks/feels totally natural, and with significant Python exposure prior to any Java/TypeScript, something I've been feeling the lack of basically since day 1. |
Parses and transpiles object comprehension syntax proposed in issue DanielXMoore#439 Tested only in limited contexts, of the 4 tests added one is failing
Parses and transpiles object comprehension syntax proposed in issue DanielXMoore#439 Tested only in limited contexts, of the 4 tests added one is failing
For anyone following this issue, #1563 gave us object comprehensions! See https://civet.dev/reference#object-comprehensions |
DONE: Object comprehensions
(based on Python's dict comprehensions)
DONE: Array flattening via spreads
This could also be achieved via
for.value.push(...item); continue
given #362, but this seems like more natural notation.The text was updated successfully, but these errors were encountered: