Slices
The Slices registry provides utilities for working with slice data structures, including functions for filtering, sorting, and transforming slices in a flexible manner.
Last updated
The Slices registry provides utilities for working with slice data structures, including functions for filtering, sorting, and transforming slices in a flexible manner.
Last updated
You can easily import all the functions from the slices
registry by including the following import statement in your code
The function creates a list from the provided elements, collecting them into a single array-like structure.
The function adds an element to the end of an existing list, extending the list by one item.
The function adds an element to the beginning of an existing list, placing the new item before all others.
The function merges multiple lists into a single, unified list, combining all elements from the provided lists.
The function divides a list into smaller, equally sized chunks based on the specified size, breaking the original list into manageable sublists.
The function removes duplicate elements from a list, ensuring that each element appears only once in the resulting list.
The function removes nil
and zero-value elements from a list, leaving only non-empty and meaningful values.
The function extracts a portion of a list, creating a new slice based on the specified start and end indices.
The function checks if a specified element is present within a collection, returning true if the element is found.
The function returns a new list that excludes the specified elements, effectively filtering out unwanted items from the original list.
The function returns all elements of a list except for the first one, effectively giving you the "rest" of the list.
The function returns all elements of a list except the last one, effectively providing the "initial" portion of the list.
The function returns the first element of a list.
The function returns the last element of a list.
The function returns a new list with the elements in reverse order, flipping the sequence of the original list.
The function sorts a list of strings in alphabetical order.
The function splits a string into a slice of substrings based on the specified separator.
This function may be renamed in the future to better reflect its purpose.
The function converts a given value into a slice of strings, handling various input types including []string
, []any
, and other slice types, ensuring flexible type conversion to a string slice.
The function generates a slice of integers starting from 0 up to, but not including, the specified count
. If count
is negative, it produces a descending slice from 0 down to count
, inclusive, stepping by -1. The function utilizes UntilStep
to dynamically determine the range and step size.
The function generates a slice of integers from start
to stop
(exclusive), incrementing by the specified step
. If step
is positive, the sequence ascends; if negative, it descends. The function returns an empty slice if the sequence is logically invalid, such as when a positive step is used but start
is greater than stop
, or vice versa.
Signature
Must version
Signature
Must version
Signature
Must version
Signature
Must version
Signature
Must version
Signature
Must version
Signature
Must version
Signature
Must version
Signature
Must version
Signature
Must version
Signature
Must version
Signature
Must version
Signature
Must version
Signature
Must version
Signature
Must version
Signature
Must version
Signature
Must version
Signature
Must version
Signature
Must version
Signature
Must version