diff options
author | Klaus Aehlig <klaus.aehlig@huawei.com> | 2024-02-15 10:39:50 +0100 |
---|---|---|
committer | Klaus Aehlig <klaus.aehlig@huawei.com> | 2024-02-15 10:39:50 +0100 |
commit | 004823e61db50e556e56360ca4f6647bdbb91b0c (patch) | |
tree | 5a0e47a289df4ea964fa7424505bf5accb710ee4 /rules/EXPRESSIONS | |
parent | 5b820def58f4d4ec30f0b3e4e8db49ce1fef8dd9 (diff) | |
parent | 289421a2c418790b3b5451a2b7d64ec9223903d7 (diff) | |
download | rules-cc-004823e61db50e556e56360ca4f6647bdbb91b0c.tar.gz |
Merge subtree 'rules' into rules-cc
Diffstat (limited to 'rules/EXPRESSIONS')
-rw-r--r-- | rules/EXPRESSIONS | 70 |
1 files changed, 3 insertions, 67 deletions
diff --git a/rules/EXPRESSIONS b/rules/EXPRESSIONS index 59efead..52a381f 100644 --- a/rules/EXPRESSIONS +++ b/rules/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"} } } } |