diff --git a/ablescript/src/variables.rs b/ablescript/src/variables.rs index ffe4cbfa..a6e4848f 100644 --- a/ablescript/src/variables.rs +++ b/ablescript/src/variables.rs @@ -118,20 +118,6 @@ impl Value { tape_len, } => (instructions.len() + tape_len) as _, Functio::Able { params, body } => (params.len() + format!("{:?}", body).len()) as _, - Functio::Chain { functios, kind } => { - let (lhs, rhs) = *functios; - match kind { - FunctioChainKind::Ordered => { - Value::Int(Value::Functio(lhs).into_i32()) - + Value::Int(Value::Functio(rhs).into_i32()) - } - FunctioChainKind::Interlaced => { - Value::Int(Value::Functio(lhs).into_i32()) - * Value::Int(Value::Functio(rhs).into_i32()) - } - } - .into_i32() - } Functio::Eval(s) => s.len() as _, }, Value::Int(i) => i, @@ -566,7 +552,38 @@ impl ops::Div for Value { })), Value::Bool(b) => Value::Bool(!b || rhs.into_bool()), Value::Abool(_) => !self + rhs, - Value::Functio(_) => todo!(), + Value::Functio(f) => { + let fraction = 1.0 / rhs.into_i32() as f64; + Value::Functio(match f { + Functio::Bf { + instructions, + tape_len, + } => { + let len = instructions.len(); + Functio::Bf { + instructions: instructions + .into_iter() + .take((len as f64 * fraction) as usize) + .collect(), + tape_len, + } + } + Functio::Able { params, body } => { + let len = body.len(); + Functio::Able { + params, + body: body + .into_iter() + .take((len as f64 * fraction) as usize) + .collect(), + } + } + Functio::Eval(s) => { + let len = s.len(); + Functio::Eval(s.chars().take((len as f64 * fraction) as usize).collect()) + } + }) + } Value::Cart(c) => { let cart_len = c.len(); let chunk_len = rhs.into_i32() as usize;