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
let t = self.heap.alloc(HeapObj::Tuple(vec![Val::int(i asi64), x]))?;
244
+
let idx = self.int_to_val(start.checked_add(i asi128))?;
245
+
let t = self.heap.alloc(HeapObj::Tuple(vec![idx, x]))?;
230
246
pairs.push(t);
231
247
}
232
248
self.alloc_and_push_list(pairs)
@@ -335,21 +351,43 @@ impl<'a> VM<'a> {
335
351
self.extract_iter(o,true)
336
352
}
337
353
338
-
/* `iter(x)`, eager flatten into a fresh List drained front-to-back by `next()`. Original isn't touched. Mirrors the universal ABI's `Op::Iter`. */
339
-
pubfncall_iter(&mutself) -> Result<(),VmErr>{
354
+
/* `iter(x)`, eager flatten into a fresh List drained front-to-back by `next()`. Original isn't touched. Mirrors the universal ABI's `Op::Iter`. The 2-arg form `iter(callable, sentinel)` calls `callable()` until it returns `sentinel`, eagerly. */
Copy file name to clipboardExpand all lines: docs/content/reference/builtins.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -82,7 +82,7 @@ print(round(1.55, 1))
82
82
83
83
### min, max
84
84
85
-
Variadic or single iterable. Accept a `default=` returned when a single iterable is empty; without it an empty input raises `ValueError`. No`key=`(transform inline). Ordering follows `<`: numbers, strings, bytes, and tuples/lists (lexicographic).
85
+
Variadic or single iterable. Accept a `default=` returned when a single iterable is empty; without it an empty input raises `ValueError`. A`key=`function selects the comparison value (the original element is returned). Ordering follows `<`: numbers, strings, bytes, and tuples/lists (lexicographic).
86
86
87
87
```python
88
88
print(min(3, 1, 4))
@@ -346,7 +346,7 @@ print(reversed("abc"))
346
346
347
347
### enumerate
348
348
349
-
Pairs each element with its index -> list of `(i, value)` tuples. No `start=`, add the offset yourself.
349
+
Pairs each element with its index -> list of `(i, value)` tuples. A second argument (positional or `start=`) sets the first index.
`next(iterator)` -> next item. Exhausted -> `StopIteration`. Two-arg `next(it, default)`returns `default` instead of raising on exhaustion.
383
383
384
384
```python
385
385
it =iter([10, 20, 30])
@@ -396,7 +396,7 @@ print(next(it))
396
396
397
397
### iter
398
398
399
-
`iter(x)` returns a fresh iterator over any iterable (list, tuple, set, dict, range, str, bytes, frozenset). Materialises a snapshot, original never mutated. Two-arg `iter(callable, sentinel)`not supported.
399
+
`iter(x)` returns a fresh iterator over any iterable (list, tuple, set, dict, range, str, bytes, frozenset). Materialises a snapshot, original never mutated. Two-arg `iter(callable, sentinel)`calls `callable()` until it returns `sentinel`, eagerly.
0 commit comments