MCPcopy Create free account
hub / github.com/GraphLite-AI/GraphLite / execute

Method execute

graphlite/src/functions/list_functions.rs:43–65  ·  view source on GitHub ↗
(&self, context: &FunctionContext)

Source from the content-addressed store, hash-verified

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

Callers 6

test_list_containsFunction · 0.45
test_list_sliceFunction · 0.45
test_list_appendFunction · 0.45
test_list_prependFunction · 0.45
test_list_lengthFunction · 0.45
test_list_reverseFunction · 0.45

Calls 5

as_listMethod · 0.80
cloneMethod · 0.80
lenMethod · 0.45
iterMethod · 0.45
as_integerMethod · 0.45

Tested by 6

test_list_containsFunction · 0.36
test_list_sliceFunction · 0.36
test_list_appendFunction · 0.36
test_list_prependFunction · 0.36
test_list_lengthFunction · 0.36
test_list_reverseFunction · 0.36