diff options
author | j.uhlig <[email protected]> | 2018-03-19 16:32:21 +0100 |
---|---|---|
committer | j.uhlig <[email protected]> | 2018-03-19 16:32:21 +0100 |
commit | df7d961bfd648e88b50eb3762af39a3cd985bc11 (patch) | |
tree | 79d2cb5f3e99fb8e0ba302ed474042d7a497905d /lib/stdlib | |
parent | f05074ac001a5f81f98c08d8812850a7d0b9ab18 (diff) | |
download | otp-df7d961bfd648e88b50eb3762af39a3cd985bc11.tar.gz otp-df7d961bfd648e88b50eb3762af39a3cd985bc11.tar.bz2 otp-df7d961bfd648e88b50eb3762af39a3cd985bc11.zip |
is_empty/1 for ordsets
Diffstat (limited to 'lib/stdlib')
-rw-r--r-- | lib/stdlib/doc/src/ordsets.xml | 9 | ||||
-rw-r--r-- | lib/stdlib/src/ordsets.erl | 9 |
2 files changed, 17 insertions, 1 deletions
diff --git a/lib/stdlib/doc/src/ordsets.xml b/lib/stdlib/doc/src/ordsets.xml index 7b590932e4..2d891d7a5a 100644 --- a/lib/stdlib/doc/src/ordsets.xml +++ b/lib/stdlib/doc/src/ordsets.xml @@ -142,6 +142,15 @@ </func> <func> + <name name="is_empty" arity="1"/> + <fsummary>Test for empty set.</fsummary> + <desc> + <p>Returns <c>true</c> if <c><anno>Ordset</anno></c> is an empty set, + otherwise <c>false</c>.</p> + </desc> + </func> + + <func> <name name="is_set" arity="1"/> <fsummary>Test for an <c>Ordset</c>.</fsummary> <desc> diff --git a/lib/stdlib/src/ordsets.erl b/lib/stdlib/src/ordsets.erl index 569407f5ef..939e147ad8 100644 --- a/lib/stdlib/src/ordsets.erl +++ b/lib/stdlib/src/ordsets.erl @@ -19,7 +19,7 @@ -module(ordsets). --export([new/0,is_set/1,size/1,to_list/1,from_list/1]). +-export([new/0,is_set/1,size/1,is_empty/1,to_list/1,from_list/1]). -export([is_element/2,add_element/2,del_element/2]). -export([union/2,union/1,intersection/2,intersection/1]). -export([is_disjoint/2]). @@ -60,6 +60,13 @@ is_set([], _) -> true. size(S) -> length(S). +%% is_empty(OrdSet) -> boolean(). +%% Return 'true' if OrdSet is an empty set, otherwise 'false'. +-spec is_empty(Ordset) -> boolean() when + Ordset :: ordset(_). + +is_empty(S) -> S=:=[]. + %% to_list(OrdSet) -> [Elem]. %% Return the elements in OrdSet as a list. |