Small fixes for user-defined functions, update readme.
This commit is contained in:
parent
ddabe282a4
commit
74e98f7e3b
2 changed files with 4 additions and 1 deletions
|
@ -60,6 +60,9 @@ Available Operators:
|
||||||
- lt: `<`: less than
|
- lt: `<`: less than
|
||||||
- load: `load`: load a key from the provided input `(load ".container.app_id")`
|
- load: `load`: load a key from the provided input `(load ".container.app_id")`
|
||||||
- has-key: `has-key`: check if a key is in the input: `(has-key ".container.app_id")`
|
- has-key: `has-key`: check if a key is in the input: `(has-key ".container.app_id")`
|
||||||
|
- let: `let`: assign a local variable: `(let x 10)`
|
||||||
|
- setq: `setq`: assign a global variable: `(setq x 11)`
|
||||||
|
- defun: `defun`: user-defined functions: `((defun greet (a) (write (+ "Hello " a "!"))) (greet "Alice"))`
|
||||||
|
|
||||||
For example: `(> (load ".container.geometry.width") 300)` would match the first window where the width is greater than 300.
|
For example: `(> (load ".container.geometry.width") 300)` would match the first window where the width is greater than 300.
|
||||||
|
|
||||||
|
|
|
@ -80,7 +80,7 @@ class Environment:
|
||||||
'<': lambda _, _l, a, b: a < b,
|
'<': lambda _, _l, a, b: a < b,
|
||||||
'>=': lambda _, _l, a, b: a >= b,
|
'>=': lambda _, _l, a, b: a >= b,
|
||||||
'<=': lambda _, _l, a, b: a <= b,
|
'<=': lambda _, _l, a, b: a <= b,
|
||||||
'+': lambda _, _l, *a: sum(a),
|
'+': lambda _, _l, *a: functools.reduce(lambda a, b: a + b, a),
|
||||||
'-': lambda _, _l, a, b: a - b,
|
'-': lambda _, _l, a, b: a - b,
|
||||||
'*': lambda _, _l, *a: functools.reduce(lambda a, b: a * b, a),
|
'*': lambda _, _l, *a: functools.reduce(lambda a, b: a * b, a),
|
||||||
'/': lambda _, _l, a, b: a // b,
|
'/': lambda _, _l, a, b: a // b,
|
||||||
|
|
Loading…
Reference in a new issue