mirror of
https://github.com/nushell/nushell
synced 2024-12-27 21:43:09 +00:00
Minor updates to variance (#2458)
This commit is contained in:
parent
d6b6b1df38
commit
965e07d8cc
1 changed files with 21 additions and 19 deletions
|
@ -81,30 +81,32 @@ impl WholeStreamCommand for SubCommand {
|
|||
entries: column_totals,
|
||||
})
|
||||
.into_untagged_value())
|
||||
};
|
||||
}?;
|
||||
|
||||
match res {
|
||||
Ok(v) => {
|
||||
if v.value.is_table() {
|
||||
Ok(OutputStream::from(
|
||||
v.table_entries()
|
||||
.map(|v| ReturnSuccess::value(v.clone()))
|
||||
.collect::<Vec<_>>(),
|
||||
))
|
||||
} else {
|
||||
Ok(OutputStream::one(ReturnSuccess::value(v)))
|
||||
}
|
||||
}
|
||||
Err(e) => Err(e),
|
||||
if res.value.is_table() {
|
||||
Ok(OutputStream::from(
|
||||
res.table_entries()
|
||||
.map(|v| ReturnSuccess::value(v.clone()))
|
||||
.collect::<Vec<_>>(),
|
||||
))
|
||||
} else {
|
||||
Ok(OutputStream::one(ReturnSuccess::value(res)))
|
||||
}
|
||||
}
|
||||
|
||||
fn examples(&self) -> Vec<Example> {
|
||||
vec![Example {
|
||||
description: "Get the variance of a list of numbers",
|
||||
example: "echo [1 2 3 4 5] | math variance",
|
||||
result: Some(vec![UntaggedValue::decimal(2).into()]),
|
||||
}]
|
||||
vec![
|
||||
Example {
|
||||
description: "Get the variance of a list of numbers",
|
||||
example: "echo [1 2 3 4 5] | math variance",
|
||||
result: Some(vec![UntaggedValue::decimal(2).into()]),
|
||||
},
|
||||
Example {
|
||||
description: "Get the sample variance of a list of numbers",
|
||||
example: "echo [1 2 3 4 5] | math variance -s",
|
||||
result: Some(vec![UntaggedValue::decimal(2.5).into()]),
|
||||
},
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue