MCPcopy Create free account
hub / github.com/dfinity/ic-repl / map

Function map

src/selector.rs:211–221  ·  view source on GitHub ↗
(helper: &MyHelper, vs: Vec<IDLValue>, func: &str)

Source from the content-addressed store, hash-verified

209}
210
211fn map(helper: &MyHelper, vs: Vec<IDLValue>, func: &str) -> Result<Vec<IDLValue>> {
212 let mut new_helper = helper.spawn();
213 let mut res = Vec::with_capacity(vs.len());
214 for v in vs.into_iter() {
215 new_helper.env.0.insert(String::new(), v);
216 let arg = Exp::Path(String::new(), Vec::new());
217 let exp = Exp::Apply(func.to_string(), vec![arg]);
218 res.push(exp.eval(&new_helper)?);
219 }
220 Ok(res)
221}
222
223fn filter(helper: &MyHelper, vs: Vec<IDLValue>, func: &str) -> Result<Vec<IDLValue>> {
224 let mut new_helper = helper.spawn();

Callers 1

projectFunction · 0.85

Calls 2

spawnMethod · 0.80
evalMethod · 0.80

Tested by

no test coverage detected