7.7
List utilities
This is a simple collection of list-processing functions which I have found helpful in general.
Note that it should not be considered as stable.
(require list-utils) | package: list-utils |
1 API
procedure
(findf-index proc lst) → (or/c #f exact-nonnegative-integer?)
proc : (-> any/c boolean?) lst : list?
Finds the index of the first element in lst such that proc returns a non-false result.
Splits a list lst into sublists such that all elements in a sublist
have the same result for proc (based on equal?).
Computes all possible splits of lst on a supplied predicate pred.
procedure
(subsequences lst) → (listof list?)
lst : list?
Returns a list of all nonempty subsequences of lst.
procedure
(replace-sublist lst sublst/i sublst/o) → list?
lst : list? sublst/i : list? sublst/o : list?
Replaces the first occurrence of the sublist sublst/i in lst with sublst/o.
procedure
(frequencies lst) → hash?
lst : list?
Produces a mapping from every unique element in lst to its (absolute) frequency in lst.
Links the n-th element in lst to index n, where n starts at 0.
procedure
lst : list? val : any/c pos : exact-nonnegative-integer?
Inserts val at position pos of lst, shifting the element that originally occupied pos (if any) one position to the right.