lib: remove upstreamed function `repeat` (`replicate`)
This commit is contained in:
parent
b5874e2bcd
commit
0137f4f5a9
|
@ -284,9 +284,7 @@ in rec {
|
||||||
inherit (lib.strings) concatStringsSep;
|
inherit (lib.strings) concatStringsSep;
|
||||||
inherit (extendedLib.strings) repeatString;
|
inherit (extendedLib.strings) repeatString;
|
||||||
|
|
||||||
inherit (lib.lists) range flatten;
|
inherit (lib.lists) range flatten replicate;
|
||||||
inherit (extendedLib.lists) repeat;
|
|
||||||
|
|
||||||
inherit (lib.attrsets) nameValuePair listToAttrs;
|
inherit (lib.attrsets) nameValuePair listToAttrs;
|
||||||
|
|
||||||
nthCds = n: [
|
nthCds = n: [
|
||||||
|
@ -296,7 +294,7 @@ in rec {
|
||||||
("." + toString n)
|
("." + toString n)
|
||||||
(".." + toString n)
|
(".." + toString n)
|
||||||
];
|
];
|
||||||
realCommand = n: "cd " + (concatStringsSep "/" (repeat ".." n));
|
realCommand = n: "cd " + (concatStringsSep "/" (replicate n ".."));
|
||||||
|
|
||||||
nthCdsAsNameValuePairs = n: map (cmd: nameValuePair cmd (realCommand n)) (nthCds n);
|
nthCdsAsNameValuePairs = n: map (cmd: nameValuePair cmd (realCommand n)) (nthCds n);
|
||||||
allCdNameValuePairs = flatten (map nthCdsAsNameValuePairs (range 1 9));
|
allCdNameValuePairs = flatten (map nthCdsAsNameValuePairs (range 1 9));
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
rec {
|
rec {
|
||||||
attrsets = import ./attrsets.nix { inherit stdlib; };
|
attrsets = import ./attrsets.nix { inherit stdlib; };
|
||||||
lists = import ./lists.nix { inherit stdlib; };
|
lists = import ./lists.nix { inherit stdlib; };
|
||||||
strings = import ./strings.nix { inherit stdlib lists; };
|
strings = import ./strings.nix { inherit stdlib; };
|
||||||
termColors = import ./termColors.nix { inherit stdlib strings; };
|
termColors = import ./termColors.nix { inherit stdlib strings; };
|
||||||
trivial = import ./trivial.nix { inherit stdlib; };
|
trivial = import ./trivial.nix { inherit stdlib; };
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,6 @@ let
|
||||||
inherit (stdlib.trivial) const;
|
inherit (stdlib.trivial) const;
|
||||||
inherit (stdlib.lists) range any all;
|
inherit (stdlib.lists) range any all;
|
||||||
in {
|
in {
|
||||||
# a -> Int -> [a]
|
|
||||||
repeat = item: times: map (const item) (range 1 times);
|
|
||||||
|
|
||||||
# [Bool] -> Bool
|
# [Bool] -> Bool
|
||||||
any' = any (boolean: boolean);
|
any' = any (boolean: boolean);
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
{ stdlib, lists }:
|
{ stdlib }:
|
||||||
let
|
let
|
||||||
inherit (stdlib.lists) length;
|
inherit (stdlib.lists) length replicate;
|
||||||
inherit (lists) repeat;
|
|
||||||
inherit (stdlib.strings) concatStringsSep replaceStrings splitString;
|
inherit (stdlib.strings) concatStringsSep replaceStrings splitString;
|
||||||
in rec {
|
in rec {
|
||||||
# String -> [String]
|
# String -> [String]
|
||||||
|
@ -15,13 +14,13 @@ in rec {
|
||||||
mapLines = splitMap "\n";
|
mapLines = splitMap "\n";
|
||||||
|
|
||||||
# String -> Int -> String
|
# String -> Int -> String
|
||||||
repeatString = string: times: concatStringsSep "" (repeat string times);
|
repeatString = string: times: concatStringsSep "" (replicate times string);
|
||||||
|
|
||||||
# Replaces any occurences in a list of strings with a single replacement.
|
# Replaces any occurences in a list of strings with a single replacement.
|
||||||
# NOTE: This function does not support regex patterns.
|
# NOTE: This function does not support regex patterns.
|
||||||
#
|
#
|
||||||
# [String] -> String -> String -> String
|
# [String] -> String -> String -> String
|
||||||
replaceStrings' = from: to: replaceStrings from (repeat to (length from));
|
replaceStrings' = from: to: replaceStrings from (replicate (length from) to);
|
||||||
|
|
||||||
# [String] -> String
|
# [String] -> String
|
||||||
unlines = concatStringsSep "\n";
|
unlines = concatStringsSep "\n";
|
||||||
|
|
Loading…
Reference in New Issue