intersperse
lib.strings.intersperse
Docs pulled from | This Revision | 11 minutes ago
Place an element between each element of a list
Inputs
separator
- Separator to add between elements
list
- Input list
Type
intersperse :: a -> [a] -> [a]
Examples
lib.strings.intersperse
usage example
intersperse "/" ["usr" "local" "bin"]
=> ["usr" "/" "local" "/" "bin"].
Noogle detected
Implementation
The following is the current implementation of this function.
intersperse =
separator:
list:
if list == [] || length list == 1
then list
else tail (lib.concatMap (x: [separator x]) list);