Nushell
Get Nu!
Getting Started
  • The Nushell Book
  • Command Reference
  • Cookbook
  • Language Reference Guide
  • Contributing Guide
Blog
  • English
  • 中文
  • Deutsch
  • Français
  • Español
  • 日本語
  • Português do Brasil
  • Русский язык
  • 한국어
GitHub
Get Nu!
Getting Started
  • The Nushell Book
  • Command Reference
  • Cookbook
  • Language Reference Guide
  • Contributing Guide
Blog
  • English
  • 中文
  • Deutsch
  • Français
  • Español
  • 日本語
  • Português do Brasil
  • Русский язык
  • 한국어
GitHub
  • Categories

    • Bits
    • Bytes
    • Chart
    • Conversions
    • Core
    • Database
    • Dataframe
    • Dataframe Or Lazyframe
    • Date
    • Debug
    • Default
    • Env
    • Experimental
    • Expression
    • Filesystem
    • Filters
    • Formats
    • Generators
    • Hash
    • History
    • Lazyframe
    • Math
    • Misc
    • Network
    • Path
    • Platform
    • Plugin
    • Prompt
    • Random
    • Removed
    • Shells
    • Strings
    • System
    • Viewers

math product for math

Returns the product of a list of numbers or the products of each column of a table.

Signature

> math product {flags} ...rest

Parameters

  • ...rest: The cell-paths/columns to operate on.

Input/output types:

inputoutput
list<number>number
rangenumber
tablerecord
recordrecord

Examples

Compute the product of a list of numbers.

> [2 3 3 4] | math product
72

Compute the product of each column in a table.

> [[a b]; [1 2] [3 4]] | math product
╭───┬───╮
│ a │ 3 │
│ b │ 8 │
╰───┴───╯

Compute the product of list-valued columns in a record.

> {alice: [2 3 4], bob: [4 5 6]} | math product
╭───────┬─────╮
│ alice │ 24  │
│ bob   │ 120 │
╰───────┴─────╯

Compute the product of a single column using a cell path.

> {alice: [2 3 4], bob: [4 5 6]} | math product alice
╭───────┬───────────╮
│ alice │ 24        │
│       │ ╭───┬───╮ │
│ bob   │ │ 0 │ 4 │ │
│       │ │ 1 │ 5 │ │
│       │ │ 2 │ 6 │ │
│       │ ╰───┴───╯ │
╰───────┴───────────╯