diff --git a/home/shellOptions.nix b/home/shellOptions.nix index ca09a44..935b2d5 100644 --- a/home/shellOptions.nix +++ b/home/shellOptions.nix @@ -284,9 +284,7 @@ in rec { inherit (lib.strings) concatStringsSep; inherit (extendedLib.strings) repeatString; - inherit (lib.lists) range flatten; - inherit (extendedLib.lists) repeat; - + inherit (lib.lists) range flatten replicate; inherit (lib.attrsets) nameValuePair listToAttrs; nthCds = n: [ @@ -296,7 +294,7 @@ in rec { ("." + 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); allCdNameValuePairs = flatten (map nthCdsAsNameValuePairs (range 1 9)); diff --git a/lib/default.nix b/lib/default.nix index 3f3bf1c..eacd15c 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -2,7 +2,7 @@ rec { attrsets = import ./attrsets.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; }; trivial = import ./trivial.nix { inherit stdlib; }; } diff --git a/lib/lists.nix b/lib/lists.nix index 604af97..3d91103 100644 --- a/lib/lists.nix +++ b/lib/lists.nix @@ -3,9 +3,6 @@ let inherit (stdlib.trivial) const; inherit (stdlib.lists) range any all; in { - # a -> Int -> [a] - repeat = item: times: map (const item) (range 1 times); - # [Bool] -> Bool any' = any (boolean: boolean); diff --git a/lib/strings.nix b/lib/strings.nix index 7031fc2..96b41b4 100644 --- a/lib/strings.nix +++ b/lib/strings.nix @@ -1,7 +1,6 @@ -{ stdlib, lists }: +{ stdlib }: let - inherit (stdlib.lists) length; - inherit (lists) repeat; + inherit (stdlib.lists) length replicate; inherit (stdlib.strings) concatStringsSep replaceStrings splitString; in rec { # String -> [String] @@ -15,13 +14,13 @@ in rec { mapLines = splitMap "\n"; # 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. # NOTE: This function does not support regex patterns. # # [String] -> String -> String -> String - replaceStrings' = from: to: replaceStrings from (repeat to (length from)); + replaceStrings' = from: to: replaceStrings from (replicate (length from) to); # [String] -> String unlines = concatStringsSep "\n";