Skip to content

Commit bd25ccb

Browse files
CopilotashyanSpada
andauthored
feat: add built-in functions, Value::map(), and new infix operators
Agent-Logs-Url: https://github.com/ashyanSpada/expression_engine_rs/sessions/4fa8d4bb-a3b9-451f-a5c8-f2bfd0df5242 Co-authored-by: ashyanSpada <22587148+ashyanSpada@users.noreply.github.com>
1 parent 7201f65 commit bd25ccb

4 files changed

Lines changed: 539 additions & 4 deletions

File tree

README.md

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,11 @@ A binary expression contains two operands separated by an operator. All the bina
153153
| * | 120 | |
154154
| % | 120 | |
155155
| / | 120 | |
156-
| beginWith | 200 | |
157-
| endWith | 200 | |
156+
| beginWith | 200 | Returns true if the left string starts with the right string |
157+
| endWith | 200 | Returns true if the left string ends with the right string |
158+
| in | 200 | Returns true if the left value is found in the right list |
159+
| notIn | 200 | Returns true if the left value is not found in the right list |
160+
| contains | 200 | Returns true if the left string contains the right string |
158161

159162
### TernaryExpression
160163

@@ -236,3 +239,49 @@ NoneExpression:
236239
```
237240

238241
The return value of the NoneExpression is `None`.
242+
243+
## Built-in Functions
244+
245+
The following functions are available without any registration:
246+
247+
### Math Functions
248+
249+
| Function | Signature | Description |
250+
| -------------- | ------------------ | --------------------------------------------------- |
251+
| min | min(x, ...) | Returns the minimum value among all numeric params |
252+
| max | max(x, ...) | Returns the maximum value among all numeric params |
253+
| sum | sum(x, ...) | Returns the sum of all numeric params |
254+
| mul | mul(x, ...) | Returns the product of all numeric params |
255+
| avg | avg(x, ...) | Returns the average of all numeric params |
256+
| abs | abs(x) | Returns the absolute value of x |
257+
| floor | floor(x) | Rounds x down to the nearest integer |
258+
| ceil | ceil(x) | Rounds x up to the nearest integer |
259+
| round | round(x) | Rounds x to the nearest integer |
260+
| pow | pow(base, exp) | Returns base raised to the power exp |
261+
| sqrt | sqrt(x) | Returns the square root of x |
262+
263+
### String Functions
264+
265+
| Function | Signature | Description |
266+
| -------------- | ------------------ | --------------------------------------------------- |
267+
| len | len(x) | Returns the length of a string, list, or map |
268+
| upper | upper(s) | Converts string s to uppercase |
269+
| lower | lower(s) | Converts string s to lowercase |
270+
| trim | trim(s) | Removes leading and trailing whitespace from s |
271+
| concat | concat(s, ...) | Concatenates all string params |
272+
| str | str(x) | Converts a value to its string representation |
273+
| num | num(x) | Converts a string or bool to a number |
274+
275+
### List Functions
276+
277+
| Function | Signature | Description |
278+
| -------------- | ------------------ | --------------------------------------------------- |
279+
| first | first(list) | Returns the first element of the list |
280+
| last | last(list) | Returns the last element of the list |
281+
282+
### Map Functions
283+
284+
| Function | Signature | Description |
285+
| -------------- | ------------------ | --------------------------------------------------- |
286+
| keys | keys(map) | Returns a list of all keys in the map |
287+
| values | values(map) | Returns a list of all values in the map |

0 commit comments

Comments
 (0)