From 58e4bdb1b95a7c7f048f38e231328054e753b898 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Tue, 11 Apr 2023 16:41:04 +0200 Subject: [PATCH] Remove enumeration support from `map` --- src/eval/array.rs | 10 ++-------- src/eval/func.rs | 20 -------------------- 2 files changed, 2 insertions(+), 28 deletions(-) diff --git a/src/eval/array.rs b/src/eval/array.rs index 6bd2eb472..b04fdab8c 100644 --- a/src/eval/array.rs +++ b/src/eval/array.rs @@ -181,15 +181,9 @@ impl Array { /// Transform each item in the array with a function. pub fn map(&self, vm: &mut Vm, func: Func) -> SourceResult { - let enumerate = func.argc() == Some(2); self.iter() - .enumerate() - .map(|(i, item)| { - let mut args = Args::new(func.span(), []); - if enumerate { - args.push(func.span(), Value::Int(i as i64)); - } - args.push(func.span(), item.clone()); + .map(|item| { + let args = Args::new(func.span(), [item.clone()]); func.call_vm(vm, args) }) .collect() diff --git a/src/eval/func.rs b/src/eval/func.rs index 93da6d7b5..d64ca732a 100644 --- a/src/eval/func.rs +++ b/src/eval/func.rs @@ -73,17 +73,6 @@ impl Func { self } - /// The number of positional arguments this function takes, if known. - pub fn argc(&self) -> Option { - match &self.repr { - Repr::Closure(closure) => closure.argc(), - Repr::With(arc) => Some(arc.0.argc()?.saturating_sub( - arc.1.items.iter().filter(|arg| arg.name.is_none()).count(), - )), - _ => None, - } - } - /// Call the function with the given arguments. pub fn call_vm(&self, vm: &mut Vm, mut args: Args) -> SourceResult { match &self.repr { @@ -346,15 +335,6 @@ impl Closure { result } - - /// The number of positional arguments this closure takes, if known. - fn argc(&self) -> Option { - if self.sink.is_some() { - return None; - } - - Some(self.params.iter().filter(|(_, default)| default.is_none()).count()) - } } impl From for Func {