| 41 | } |
| 42 | |
| 43 | fn execute(&self, context: &FunctionContext) -> FunctionResult<Value> { |
| 44 | if context.arguments.len() != 2 { |
| 45 | return Err(FunctionError::InvalidArgumentCount { |
| 46 | expected: 2, |
| 47 | actual: context.arguments.len(), |
| 48 | }); |
| 49 | } |
| 50 | |
| 51 | let list_arg = &context.arguments[0]; |
| 52 | let element_arg = &context.arguments[1]; |
| 53 | |
| 54 | // Extract list values |
| 55 | let list_values = list_arg |
| 56 | .as_list() |
| 57 | .ok_or_else(|| FunctionError::InvalidArgumentType { |
| 58 | message: "First argument must be a list".to_string(), |
| 59 | })?; |
| 60 | |
| 61 | // Check if any element in the list matches the search element |
| 62 | let contains = list_values.iter().any(|item| item == element_arg); |
| 63 | |
| 64 | Ok(Value::Boolean(contains)) |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | /// LIST_SLICE function: extract sublist from start to end indices |