Array Utilities
Array Utilities
Generic, dependency-free array helpers (IsEmpty, Last, MapTo, Filter, FindFirst, Any, All, CountWhere, Swap) as parametric extension methods.
Original, compile-verified Verse by Bizanator (Biloxi Studios). Clean-room sample you can drop into a UEFN project and adapt.
-
# Array Utilities — Biloxi Studios Inc. # # Small, generic, dependency-free helpers for working with arrays in Verse, # written as parametric (`where t:type`) functions and extension methods so they # work for any element type. Import the module and call e.g. `MyArray.IsEmpty[]`. # # Teaches: parametric types, <decides>/<transacts> effects, extension-method # syntax `(Receiver:type).Method()`, predicate callbacks, and option results. using { /Verse.org/Simulation } array_utils<public> := module: # Succeeds when the array has no elements. Use in a failure context: # if (MyArray.IsEmpty[]) { ... } (Source:[]t where t:type).IsEmpty<public>()<decides><transacts>:void = Source.Length = 0 # Return the last element, or false (the empty option) when the array is empty. (Source:[]t where t:type).Last<public>()<transacts>:?t = if (Element := Source[Source.Length - 1]): option{Element} else: false
You're reading a preview
The full reference is free for BrainDeadGuild Discord members — sign in to read it all, or open the original at the source.
Sign in with your BrainDead.TV / BrainDeadGuild Discord account for full access.