diff options
author | Oliver Reiche <oliver.reiche@huawei.com> | 2023-08-10 11:58:18 +0200 |
---|---|---|
committer | Oliver Reiche <oliver.reiche@huawei.com> | 2023-08-16 15:30:32 +0200 |
commit | f61161f05e88b42e9ee141a8fd4809f0e4f4e0c6 (patch) | |
tree | 18527f382ae7115b878658c74753a2665e6df0e6 | |
parent | ec6dc0a5b6f5a8320f02ce926be3ba01e24a27ff (diff) | |
download | rules-cc-f61161f05e88b42e9ee141a8fd4809f0e4f4e0c6.tar.gz |
rules: Implement nub_left for PATH
-rw-r--r-- | EXPRESSIONS | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/EXPRESSIONS b/EXPRESSIONS index c84ebf4..59efead 100644 --- a/EXPRESSIONS +++ b/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"} + } + } } |