mirror of
https://github.com/nushell/nushell
synced 2024-12-28 14:03: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,
|
entries: column_totals,
|
||||||
})
|
})
|
||||||
.into_untagged_value())
|
.into_untagged_value())
|
||||||
};
|
}?;
|
||||||
|
|
||||||
match res {
|
if res.value.is_table() {
|
||||||
Ok(v) => {
|
Ok(OutputStream::from(
|
||||||
if v.value.is_table() {
|
res.table_entries()
|
||||||
Ok(OutputStream::from(
|
.map(|v| ReturnSuccess::value(v.clone()))
|
||||||
v.table_entries()
|
.collect::<Vec<_>>(),
|
||||||
.map(|v| ReturnSuccess::value(v.clone()))
|
))
|
||||||
.collect::<Vec<_>>(),
|
} else {
|
||||||
))
|
Ok(OutputStream::one(ReturnSuccess::value(res)))
|
||||||
} else {
|
|
||||||
Ok(OutputStream::one(ReturnSuccess::value(v)))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Err(e) => Err(e),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn examples(&self) -> Vec<Example> {
|
fn examples(&self) -> Vec<Example> {
|
||||||
vec![Example {
|
vec![
|
||||||
description: "Get the variance of a list of numbers",
|
Example {
|
||||||
example: "echo [1 2 3 4 5] | math variance",
|
description: "Get the variance of a list of numbers",
|
||||||
result: Some(vec![UntaggedValue::decimal(2).into()]),
|
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