mirror of
https://github.com/PaddiM8/kalker.git
synced 2024-12-12 17:40:52 +01:00
Added 'length' function and added 'permutations' as an alias to 'perms' function
This commit is contained in:
parent
d4a9dad153
commit
707114006b
@ -74,6 +74,7 @@ lazy_static! {
|
||||
m.insert("iverson", (UnaryFuncInfo(iverson, Other), ""));
|
||||
m.insert("Im", (UnaryFuncInfo(im, Other), ""));
|
||||
m.insert("ln", (UnaryFuncInfo(ln, Other), ""));
|
||||
m.insert("length", (UnaryFuncInfo(length, Other), ""));
|
||||
m.insert("log", (UnaryFuncInfo(log, Other), ""));
|
||||
m.insert("Re", (UnaryFuncInfo(re, Other), ""));
|
||||
m.insert("round", (UnaryFuncInfo(round, Other), ""));
|
||||
@ -109,6 +110,7 @@ lazy_static! {
|
||||
m.insert("max", VectorFuncInfo(max, Other));
|
||||
m.insert("min", VectorFuncInfo(min, Other));
|
||||
m.insert("perms", VectorFuncInfo(perms, Other));
|
||||
m.insert("permutations", VectorFuncInfo(perms, Other));
|
||||
m
|
||||
};
|
||||
}
|
||||
@ -720,6 +722,14 @@ pub mod funcs {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn length(x: KalkValue) -> KalkValue {
|
||||
match x {
|
||||
KalkValue::Vector(values) => KalkValue::from(values.len() as f64),
|
||||
KalkValue::Matrix(rows) => KalkValue::from(rows.len() as f64),
|
||||
_ => KalkValue::from(0f64),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn max(x: KalkValue) -> KalkValue {
|
||||
let values = as_vector_or_return!(x);
|
||||
let mut max = &values[0];
|
||||
|
Loading…
Reference in New Issue
Block a user