summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ataxic_sugar.erl30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/ataxic_sugar.erl b/src/ataxic_sugar.erl
index 556e08a..eb0ef57 100644
--- a/src/ataxic_sugar.erl
+++ b/src/ataxic_sugar.erl
@@ -12,6 +12,7 @@
[
update_array_cell/2,
update_orddict_element/2,
+ update_ordset/2,
nop/0
]
).
@@ -84,3 +85,32 @@ update_orddict_element (IX, OP) ->
-spec nop () -> ataxic:basic().
nop () -> ataxic:sequence([]).
+
+-spec update_ordset (ordsets:ordset(), ordsets:ordeset()) -> ataxic:basic().
+update_ordset (Old, New) ->
+ Remove = ordsets:substract(Old, New),
+ Add = ordsets:substract(New, Old),
+
+ ataxic:sequence
+ (
+ [
+ ataxic:apply_function
+ (
+ ordsets,
+ substract,
+ [
+ ataxic:current_value(),
+ ataxic:constant(Remove)
+ ]
+ ),
+ ataxic:apply_function
+ (
+ ordsets,
+ union,
+ [
+ ataxic:current_value(),
+ ataxic:constant(Add)
+ ]
+ )
+ ]
+ ).