diff options
author | Alyssa Ross <hi@alyssa.is> | 2019-08-22 13:47:37 +0000 |
---|---|---|
committer | Alyssa Ross <hi@alyssa.is> | 2019-08-22 18:22:22 +0000 |
commit | 1b9a13c4689af7e088eb7af5589f8c811282846a (patch) | |
tree | 3ed032953008280fb94ef894c869ff3e2a2f7865 /nixpkgs/lib/lists.nix | |
parent | 4999a38db7c5de0ea9f514a12ecd4133cce647f3 (diff) | |
parent | 1412af4b2cfae71d447164097d960d426e9752c0 (diff) | |
download | nixlib-1b9a13c4689af7e088eb7af5589f8c811282846a.tar nixlib-1b9a13c4689af7e088eb7af5589f8c811282846a.tar.gz nixlib-1b9a13c4689af7e088eb7af5589f8c811282846a.tar.bz2 nixlib-1b9a13c4689af7e088eb7af5589f8c811282846a.tar.lz nixlib-1b9a13c4689af7e088eb7af5589f8c811282846a.tar.xz nixlib-1b9a13c4689af7e088eb7af5589f8c811282846a.tar.zst nixlib-1b9a13c4689af7e088eb7af5589f8c811282846a.zip |
Merge remote-tracking branch 'channels/nixos-unstable'
Diffstat (limited to 'nixpkgs/lib/lists.nix')
-rw-r--r-- | nixpkgs/lib/lists.nix | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/nixpkgs/lib/lists.nix b/nixpkgs/lib/lists.nix index 30d87ece6641..e4fcf959b60c 100644 --- a/nixpkgs/lib/lists.nix +++ b/nixpkgs/lib/lists.nix @@ -21,6 +21,19 @@ rec { */ singleton = x: [x]; + /* Apply the function to each element in the list. Same as `map`, but arguments + flipped. + + Type: forEach :: [a] -> (a -> b) -> [b] + + Example: + forEach [ 1 2 ] (x: + toString x + ) + => [ "1" "2" ] + */ + forEach = xs: f: map f xs; + /* “right fold” a binary function `op` between successive elements of `list` with `nul' as the starting value, i.e., `foldr op nul [x_1 x_2 ... x_n] == op x_1 (op x_2 ... (op x_n nul))`. |