--- a/DOCUMENTATION.markdown Wed Sep 27 20:03:21 2017 -0400
+++ b/DOCUMENTATION.markdown Fri Oct 13 01:32:30 2017 -0400
@@ -1193,6 +1193,16 @@
+### `HSET-REDUCE` (function)
+
+ (HSET-REDUCE HSET FUNCTION &KEY (INITIAL-VALUE NIL IVP))
+
+Reduce `function` over the elements of `hset`.
+
+ The order in which the elements are processed is undefined.
+
+
+
### `HSET-REMOVE!` (function)
(HSET-REMOVE! HSET &REST ELEMENTS)
--- a/losh.lisp Wed Sep 27 20:03:21 2017 -0400
+++ b/losh.lisp Fri Oct 13 01:32:30 2017 -0400
@@ -2749,6 +2749,18 @@
new))
+(define-hset-op hset-reduce (hset function &key (initial-value nil ivp))
+ "Reduce `function` over the elements of `hset`.
+
+ The order in which the elements are processed is undefined.
+
+ "
+ (if ivp
+ (iterate (for (n nil) :in-hashtable storage)
+ (reducing n by function :initial-value initial-value))
+ (iterate (for (n nil) :in-hashtable storage)
+ (reducing n by function))))
+
(define-hset-op hset-elements (hset)
"Return a fresh list containing the elements of `hset`."
(hash-table-keys storage))
--- a/package.lisp Wed Sep 27 20:03:21 2017 -0400
+++ b/package.lisp Fri Oct 13 01:32:30 2017 -0400
@@ -154,7 +154,7 @@
:hset-filter!
:hset-map
:hset-map!
- ))
+ :hset-reduce))
(defpackage :losh.hash-tables
(:documentation "Utilities for operating on hash tables.")