| summaryrefslogtreecommitdiff | 
diff options
| author | nsensfel <SpamShield0@noot-noot.org> | 2019-04-23 17:21:52 +0200 | 
|---|---|---|
| committer | nsensfel <SpamShield0@noot-noot.org> | 2019-04-23 17:21:52 +0200 | 
| commit | 8afce582af1fedd5d65582f2fec79a003c4f2a5c (patch) | |
| tree | 715ad21baf859b46453f46905d69c40fdf882877 /src/ataxic_sugar.erl | |
| parent | 68830acd790f3ccc28fe4b93ff427834fce6e8ae (diff) | |
Adds an ordset update function.
Diffstat (limited to 'src/ataxic_sugar.erl')
| -rw-r--r-- | src/ataxic_sugar.erl | 30 | 
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) +            ] +         ) +      ] +   ). | 


