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

matrix map for filters

Apply a closure to each element of a matrix and return a new matrix.

Signature

> matrix map {flags} (closure)

Parameters

  • closure: The closure to apply to each element.

Input/output types:

inputoutput
matrixmatrix

Examples

Double each element in a matrix

> [[1 2] [3 4]] | into matrix | matrix map {|e| $e * 2} | matrix into-nu | to nuon
[[2.0, 4.0], [6.0, 8.0]]

Add 10 to each element of an identity matrix

> matrix identity 2 | matrix map {|e| $e + 10} | matrix into-nu | to nuon
[[11.0, 10.0], [10.0, 11.0]]