Added isEmptySet/isEmptyMap

This commit is contained in:
Dmitry Boulytchev 2021-03-24 18:51:25 +07:00
parent 8359b674f8
commit 849162aa92
4 changed files with 13 additions and 1 deletions

Binary file not shown.

View file

@ -196,6 +196,8 @@ Maps are immutable structures with the following interface:
\descr{\lstinline|fun emptyMap (f)|}{Creates an empty map. An argument is a comparison function, which returns zero, positive or negative integer values depending on \descr{\lstinline|fun emptyMap (f)|}{Creates an empty map. An argument is a comparison function, which returns zero, positive or negative integer values depending on
the order of its arguments.} the order of its arguments.}
\descr{\lstinline|fun isEmptyMap (m)|}{Returns true if an argument map is empty.}
\descr{\lstinline|fun compareOf (m)|}{Returns a comparison function, associated with the map given as an argument.} \descr{\lstinline|fun compareOf (m)|}{Returns a comparison function, associated with the map given as an argument.}
\descr{\lstinline|fun addMap (m, k, v)|}{Adds a binding of a key "\lstinline|k|" to a value "\lstinline|v|" into a map "\lstinline|m|". As a result, a new map is \descr{\lstinline|fun addMap (m, k, v)|}{Adds a binding of a key "\lstinline|k|" to a value "\lstinline|v|" into a map "\lstinline|m|". As a result, a new map is
@ -226,6 +228,8 @@ Sets are immutable structures with the following interface:
\descr{\lstinline|fun emptySet (f)|}{Creates an empty set. An argument is a comparison function, which returns zero, positive or negative integer values depending on \descr{\lstinline|fun emptySet (f)|}{Creates an empty set. An argument is a comparison function, which returns zero, positive or negative integer values depending on
the order of its arguments.} the order of its arguments.}
\descr{\lstinline|fun isEmptySet (m)|}{Returns true if an argument set is empty.}
\descr{\lstinline|fun compareOf (m)|}{Returns a comparison function, associated with the set given as an argument.} \descr{\lstinline|fun compareOf (m)|}{Returns a comparison function, associated with the set given as an argument.}
\descr{\lstinline|fun addSet (s, v)|}{Adds an element "\lstinline|v|" into a set "\lstinline|s|" and returns a new set.} \descr{\lstinline|fun addSet (s, v)|}{Adds an element "\lstinline|v|" into a set "\lstinline|s|" and returns a new set.}

View file

@ -1 +1 @@
let version = "Version 1.10, f1384146c, Sun Mar 14 07:08:07 2021 +0300" let version = "Version 1.10, 8359b674f, Sat Mar 20 13:46:03 2021 +0300"

View file

@ -214,6 +214,10 @@ public fun emptyMap (compare) {
[{}, compare] [{}, compare]
} }
public fun isEmptyMap ([l, _]) {
case l of {} -> true | _ -> false esac
}
public fun addMap (m, k, v) { public fun addMap (m, k, v) {
insertColl (m, k, v, Map) insertColl (m, k, v, Map)
} }
@ -251,6 +255,10 @@ public fun emptySet (compare) {
[{}, compare] [{}, compare]
} }
public fun isEmptySet (s) {
isEmptyMap (s)
}
public fun addSet (s, v) { public fun addSet (s, v) {
insertColl (s, v, true, Set) insertColl (s, v, true, Set)
} }