mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-14 14:10:33 +03:00
lib.strings: add replicate
`strings.replicate` returns n copies of a string, concatenated into a new string Co-authored-by: Silvan Mosberger <github@infinisil.com>
This commit is contained in:
parent
f320b0d46e
commit
206d20426c
2 changed files with 19 additions and 0 deletions
|
@ -144,6 +144,20 @@ rec {
|
|||
*/
|
||||
concatLines = concatMapStrings (s: s + "\n");
|
||||
|
||||
/*
|
||||
Replicate a string n times,
|
||||
and concatenate the parts into a new string.
|
||||
|
||||
Type: replicate :: int -> string -> string
|
||||
|
||||
Example:
|
||||
replicate 3 "v"
|
||||
=> "vvv"
|
||||
replicate 5 "hello"
|
||||
=> "hellohellohellohellohello"
|
||||
*/
|
||||
replicate = n: s: concatStrings (lib.lists.replicate n s);
|
||||
|
||||
/* Construct a Unix-style, colon-separated search path consisting of
|
||||
the given `subDir` appended to each of the given paths.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue