diff options
author | Oliver Reiche <oliver.reiche@huawei.com> | 2023-08-16 15:38:38 +0200 |
---|---|---|
committer | Oliver Reiche <oliver.reiche@huawei.com> | 2023-08-16 15:38:38 +0200 |
commit | 22a280141becf3e41652368794b2a815390c7472 (patch) | |
tree | d423afe5535bf9262725e6a2488ba18e37dbd615 /rules/EXPRESSIONS | |
parent | cdca4eff0264795d4c36fcb89aaf174a2a4151bd (diff) | |
parent | 54bb2a33b3e36123f8f411f77ec8e76f5b021e3d (diff) | |
download | rules-cc-22a280141becf3e41652368794b2a815390c7472.tar.gz |
Merge commit '54bb2a33b3e36123f8f411f77ec8e76f5b021e3d' into rules/rules-cc
Diffstat (limited to 'rules/EXPRESSIONS')
-rw-r--r-- | rules/EXPRESSIONS | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/rules/EXPRESSIONS b/rules/EXPRESSIONS index c84ebf4..59efead 100644 --- a/rules/EXPRESSIONS +++ b/rules/EXPRESSIONS @@ -273,4 +273,35 @@ } } } +, "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": "nub_right", "$1": {"type": "var", "name": "list"}}] + ] + , "body": {"type": "CALL_EXPRESSION", "name": "reverse"} + } + } } |