diff options
author | Klaus Aehlig <klaus.aehlig@huawei.com> | 2024-02-14 10:49:57 +0100 |
---|---|---|
committer | Klaus Aehlig <klaus.aehlig@huawei.com> | 2024-02-15 10:35:01 +0100 |
commit | 2b9d1ef05865718b9af3f393bd09232b6220b774 (patch) | |
tree | 724eb18073331ab3cf5b85aed409791dcf977650 /EXPRESSIONS | |
parent | a513b2e823dc6a2e37ae1fad6924b3d5c34dabf0 (diff) | |
download | rules-cc-2b9d1ef05865718b9af3f393bd09232b6220b774.tar.gz |
Remove unnecessarily quadratic expressions
... not that everyone has updated to 1.2 or later we can use
the built-in expressions "reverse" and "set".
Diffstat (limited to 'EXPRESSIONS')
-rw-r--r-- | EXPRESSIONS | 70 |
1 files changed, 3 insertions, 67 deletions
diff --git a/EXPRESSIONS b/EXPRESSIONS index 59efead..52a381f 100644 --- a/EXPRESSIONS +++ b/EXPRESSIONS @@ -226,82 +226,18 @@ } } } -, "contains": - { "doc": ["Returns the item if it is in the list or \"null\" otherwise."] - , "vars": ["list", "item", "list_prefix"] - , "vars_doc": - { "list": ["The list to look for the item."] - , "item": ["The item to look for in the list."] - , "list_prefix": - [ "An optional string, which every item in the list is prefixed with" - , "before comparison. Note that the returned item is not prefixed." - ] - } - , "expression": - { "type": "let*" - , "bindings": - [ [ "result" - , { "type": "++" - , "$1": - { "type": "foreach" - , "var": "entry" - , "range": {"type": "var", "name": "list"} - , "body": - { "type": "if" - , "cond": - { "type": "==" - , "$1": - { "type": "join" - , "$1": - [ {"type": "var", "name": "list_prefix", "default": ""} - , {"type": "var", "name": "entry"} - ] - } - , "$2": {"type": "var", "name": "item"} - } - , "then": [{"type": "var", "name": "entry"}] - } - } - } - ] - ] - , "body": - { "type": "if" - , "cond": {"type": "var", "name": "result"} - , "then": {"type": "join", "$1": {"type": "var", "name": "result"}} - , "else": null - } - } - } -, "reverse_list": - { "doc": ["Returns the list in reverse order."] - , "vars": ["list"] - , "vars_doc": {"list": ["The list to reverse."]} - , "expression": - { "type": "foldl" - , "var": "item" - , "start": [] - , "accum_var": "out" - , "range": {"type": "var", "name": "list"} - , "body": - { "type": "++" - , "$1": - [[{"type": "var", "name": "item"}], {"type": "var", "name": "out"}] - } - } - } , "nub_left": { "doc": ["Removes all but the leftmost duplicate from the list."] , "vars": ["list"] , "vars_doc": {"list": ["The list to remove duplicates from."]} - , "imports": {"reverse": "reverse_list"} , "expression": { "type": "let*" , "bindings": - [ ["list", {"type": "CALL_EXPRESSION", "name": "reverse"}] + [ ["list", {"type": "reverse", "$1": {"type": "var", "name": "list"}}] , ["list", {"type": "nub_right", "$1": {"type": "var", "name": "list"}}] + , ["list", {"type": "reverse", "$1": {"type": "var", "name": "list"}}] ] - , "body": {"type": "CALL_EXPRESSION", "name": "reverse"} + , "body": {"type": "var", "name": "list"} } } } |