diff options
author | Profpatsch <mail@profpatsch.de> | 2018-08-06 01:36:09 +0200 |
---|---|---|
committer | Profpatsch <mail@profpatsch.de> | 2018-09-06 18:14:27 +0200 |
commit | 3e45b61a9920466a8ea06b8ad9350d56ade435bc (patch) | |
tree | 1913cb4951336a37ed9921a538db5a50c7b62008 /lib/lists.nix | |
parent | 320cdecd1697020cb367adc1f8408dbf689ca254 (diff) |
lib/trivial: add a few examples of usage of assertMsg/assertOneOf
Diffstat (limited to 'lib/lists.nix')
-rw-r--r-- | lib/lists.nix | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/lists.nix b/lib/lists.nix index 288882924fff1..9a75f179e964a 100644 --- a/lib/lists.nix +++ b/lib/lists.nix @@ -509,7 +509,8 @@ rec { => 3 */ last = list: - assert list != []; elemAt list (length list - 1); + assert assertMsg (list != []) "lists.last: list must not be empty!"; + elemAt list (length list - 1); /* Return all elements but the last @@ -517,7 +518,9 @@ rec { init [ 1 2 3 ] => [ 1 2 ] */ - init = list: assert list != []; take (length list - 1) list; + init = list: + assert assertMsg (list != []) "lists.init: list must not be empty!"; + take (length list - 1) list; /* return the image of the cross product of some lists by a function |