ruuda / rcl

A reasonable configuration language
https://rcl-lang.org
Apache License 2.0
197 stars 8 forks source link

Add List.enumerate method #32

Closed ruuda closed 8 months ago

ruuda commented 8 months ago

I've found I needed this in a few places. You can already do it by iterating over std.range:

[for i, v in xs.enumerate(): ...]

is equivalent to

[
  for i in std.range(0, xs.len()):
  let v = xs[i];
  ...
]

but having it built-in is just slightly more convenient. It's a bit of a shame that we have to construct the entire dict just to iterate over it, but the focus of RCL right now is not performance.