diff --git a/src/Std/Iteration.cs b/src/Std/Iteration.cs index 0ad1485..3af631d 100644 --- a/src/Std/Iteration.cs +++ b/src/Std/Iteration.cs @@ -56,7 +56,7 @@ public static RuntimeGenerator Append(IEnumerable items, RuntimeO public static RuntimeObject At(IEnumerable items, RuntimeObject index, RuntimeObject? fallback = null) { if (items is not IIndexable indexable) - return items.ElementAt((int)index.As().Value); + return items.ElementAtOrDefault((int)index.As().Value) ?? RuntimeNil.Value; try { @@ -652,11 +652,8 @@ private static IEnumerable Window(IEnumerable valu } } - if (buffer.Any()) + if (buffer.Count == size) { - while (buffer.Count < size) - buffer.Enqueue(RuntimeNil.Value); - yield return new RuntimeList(buffer.ToList()); buffer.Clear(); }