1 API
1API
8.18
top
← prev up next →

List utilitiesπŸ”— i

Vincent Nys

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.

1APIπŸ”— i

procedure

( findf-index proclst)(or/c #fexact-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.

procedure

( group-by proclst)list?

proc:(-> any/c any/c )
lst:list?
Splits a list lst into sublists such that all elements in a sublist have the same result for proc (based on equal? ).

procedure

( all-splits-on predlst)(listof list? )

pred:(-> any/c boolean? )
lst:list?
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 lstsublst/isublst/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

( splice-in lstvalpos)list?

lst:list?
val:any/c
Inserts val at position pos of lst, shifting the element that originally occupied pos (if any) one position to the right.

top
← prev up next →

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /