Git things beyond your comprehension mortals

This commit is contained in:
Erin 2021-12-09 00:34:41 +01:00 committed by ondra05
commit dc8f72bcf7

View file

@ -118,20 +118,6 @@ impl Value {
tape_len, tape_len,
} => (instructions.len() + tape_len) as _, } => (instructions.len() + tape_len) as _,
Functio::Able { params, body } => (params.len() + format!("{:?}", body).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 _, Functio::Eval(s) => s.len() as _,
}, },
Value::Int(i) => i, Value::Int(i) => i,
@ -566,7 +552,38 @@ impl ops::Div for Value {
})), })),
Value::Bool(b) => Value::Bool(!b || rhs.into_bool()), Value::Bool(b) => Value::Bool(!b || rhs.into_bool()),
Value::Abool(_) => !self + rhs, 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) => { Value::Cart(c) => {
let cart_len = c.len(); let cart_len = c.len();
let chunk_len = rhs.into_i32() as usize; let chunk_len = rhs.into_i32() as usize;