You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I propose that it, the builtin variable which captures the iterator element under evaluation inside a map/filter function, is joined by index, a builtin variable that captures how many iterations have been evaluated so far.
An example:
import arrays
fn drop_even_letters(s string) !string {
return arrays.reduce(s.bytes()
.filter(index % 2 == 0)
.map(it.ascii_str()), fn (a string, b string) string {
return a + b
})
}
fn main() {
println(drop_even_letters('Hello, world!')!) // Hlo ol!
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I propose that
it
, the builtin variable which captures the iterator element under evaluation inside a map/filter function, is joined byindex
, a builtin variable that captures how many iterations have been evaluated so far.An example:
Beta Was this translation helpful? Give feedback.
All reactions