lib: init strings.join (#446278)

Changed files
+41
lib
+1
lib/default.nix
···
hasInfix
hasPrefix
hasSuffix
stringToCharacters
stringAsChars
escape
···
hasInfix
hasPrefix
hasSuffix
+
join
stringToCharacters
stringAsChars
escape
+30
lib/strings.nix
···
;
/**
Concatenate a list of strings.
# Type
···
;
/**
+
Concatenates a list of strings with a separator between each element.
+
+
# Inputs
+
+
`sep`
+
: Separator to add between elements
+
+
`list`
+
: List of strings that will be joined
+
+
# Type
+
+
```
+
join :: string -> [ string ] -> string
+
```
+
+
# Examples
+
:::{.example}
+
## `lib.strings.join` usage example
+
+
```nix
+
join ", " ["foo" "bar"]
+
=> "foo, bar"
+
```
+
+
:::
+
*/
+
join = builtins.concatStringsSep;
+
+
/**
Concatenate a list of strings.
# Type
+10
lib/tests/misc.nix
···
id
ifilter0
isStorePath
lazyDerivation
length
lists
···
};
# STRINGS
testConcatMapStrings = {
expr = concatMapStrings (x: x + ";") [
···
id
ifilter0
isStorePath
+
join
lazyDerivation
length
lists
···
};
# STRINGS
+
+
testJoin = {
+
expr = join "," [
+
"a"
+
"b"
+
"c"
+
];
+
expected = "a,b,c";
+
};
testConcatMapStrings = {
expr = concatMapStrings (x: x + ";") [