| summaryrefslogtreecommitdiff | 
diff options
| author | Nathanael Sensfelder <SpamShield0@MultiAgentSystems.org> | 2019-04-26 23:21:22 +0200 | 
|---|---|---|
| committer | Nathanael Sensfelder <SpamShield0@MultiAgentSystems.org> | 2019-04-26 23:21:22 +0200 | 
| commit | d4ea952032b099a4674c27e964ab6ec421c690f4 (patch) | |
| tree | 95ff353e25c971e1c88ed12236aa54b2d541c71f /src/ataxic_sugar.erl | |
| parent | 707e875456b7d8dcc37aaa8f92b16e984b534045 (diff) | |
Dubious way to have lazy orddict updates.
I want to keep the benefits of orddict:fetch vs orddict:find, but still
be able to re-use the existing code when adding a new element.
Diffstat (limited to 'src/ataxic_sugar.erl')
| -rw-r--r-- | src/ataxic_sugar.erl | 32 | 
1 files changed, 19 insertions, 13 deletions
| diff --git a/src/ataxic_sugar.erl b/src/ataxic_sugar.erl index 3098196..7f6e441 100644 --- a/src/ataxic_sugar.erl +++ b/src/ataxic_sugar.erl @@ -64,20 +64,26 @@ update_orddict_element (IX, OP) ->        store,        [           ataxic:constant(IX), -         ataxic:sequence           ( -            [ -               ataxic:apply_function -               ( -                  orddict, -                  fetch, -                  [ -                     ataxic:constant(IX), -                     ataxic:current_value() -                  ] -               ), -               OP -            ] +            case ataxic:is_constant(OP) of +               true -> OP; +               false -> +                  ataxic:sequence +                  ( +                     [ +                        ataxic:apply_function +                        ( +                           orddict, +                           fetch, +                           [ +                              ataxic:constant(IX), +                              ataxic:current_value() +                           ] +                        ), +                        OP +                     ] +                  ) +            end           ),           ataxic:current_value()        ] | 


