Skip to content

Commit

Permalink
std: Add 'iter::collect'
Browse files Browse the repository at this point in the history
  • Loading branch information
PaddiM8 committed Dec 1, 2023
1 parent 1e4b2a9 commit 821727b
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/Std/Iteration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,15 @@ public static RuntimeObject At(IIndexable<RuntimeObject> items, RuntimeObject in
public static RuntimeList Chunks(IEnumerable<RuntimeObject> items, RuntimeInteger size)
=> new(items.Chunk((int)size.Value).Select(x => new RuntimeList(x)));

/// <summary>
/// Some standard library functions return lazily evaluated Iterables. This function
/// forces an Iterable's items to be evaluated right away.
/// </summary>
/// <param name="items">The Iterable to collect.</param>
[ElkFunction("collect")]
public static RuntimeList Collect(IEnumerable<RuntimeObject> items)
=> new(items.ToList());

/// <param name="first">The first Iterable.</param>
/// <param name="second">The second Iterable.</param>
/// <returns>A new list containing the items of both the the given Iterables.</returns>
Expand Down

0 comments on commit 821727b

Please sign in to comment.