Math
math— Use mathematical functions as aggregate functions on a list of numbers or tables.math abs— Returns the absolute value of a number.math arccos— Returns the arccosine of the number.math arccosh— Returns the inverse of the hyperbolic cosine function.math arcsin— Returns the arcsine of the number.math arcsinh— Returns the inverse of the hyperbolic sine function.math arctan— Returns the arctangent of the number.math arctanh— Returns the inverse of the hyperbolic tangent function.math avg— Returns the average of a list of numbers.math cbrt— Returns the real-valued cube root of the input number.math ceil— Returns the ceil of a number (smallest integer greater than or equal to that number).math cos— Returns the cosine of the number.math cosh— Returns the hyperbolic cosine of the number.math exp— Returns e raised to the power of x.math floor— Returns the floor of a number (largest integer less than or equal to that number).math ln— Returns the natural logarithm. Base: (math e).math log— Returns the logarithm for an arbitrary base.math max— Returns the maximum of a list of values, or of columns in a table.math median— Computes the median of a list of numbers.math min— Finds the minimum within a list of values or tables.math mode— Returns the most frequent element(s) from a list of numbers or tables.math product— Returns the product of a list of numbers or the products of each column of a table.math round— Returns the input number rounded to the specified precision.math sin— Returns the sine of the number.math sinh— Returns the hyperbolic sine of the number.math sqrt— Returns the square root of the input number.math stddev— Returns the standard deviation of a list of numbers, or of each column in a table.math sum— Returns the sum of a list of numbers or of each column in a table.math tan— Returns the tangent of the number.math tanh— Returns the hyperbolic tangent of the number.math variance— Returns the variance of a list of numbers or of each column in a table.
Ported from nushell/nushell.github.io. Copyright (c) 2021 Nushell Project. MIT License.
Tips
Intro
math abs drops the sign.
(-3) | math abs
math sum adds a list.
[1 2 3] | math sum
Basic
Sum, then take the absolute value.
[1 2 3] | math sum | math abs
math avg and math round meet at an integer.
[1 2 3 4] | math avg | math round
Intermediate
Sum, convert, and count.
[1 2 3 4] | math sum | into string | str length
Take abs inside a closure, then sum.
[1 2 3] | each {|n| $n | math abs} | math sum
Advanced
Four math and text steps.
[1 2 3 4] | math sum | into string | str length | math abs