File: flatten-doc.m2

package info (click to toggle)
macaulay2 1.25.05%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 172,152 kB
  • sloc: cpp: 107,824; ansic: 16,193; javascript: 4,189; makefile: 3,899; lisp: 702; yacc: 604; sh: 476; xml: 177; perl: 114; lex: 65; python: 33
file content (41 lines) | stat: -rw-r--r-- 1,010 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
-- Status: rewritten July 2018
-- Author: Lily Silverstein

doc///
 Key
  flatten
  (flatten, VisibleList)
  (flatten, Matrix)
 Headline
  flatten a nested list or a matrix
 Usage
  flatten x
 Inputs
  x:List
   or @TO Matrix@
 Outputs
  :List
   or matrix obtained by removing braces one level in
 Description
  Text
   If {\tt x} is a list, then {\tt flatten x} effectively removes
   the braces surrounding any elements of {\tt x} that happen to
   be lists.
  Example
   flatten {{2,3,4}, {{5}, 6}, 7}
  Text
   If {\tt x} is a matrix, then {\tt flatten x} puts the elements of {\tt x} in a 
   single row, {\em ordered by column}.
   If {\tt x} is an $m\times n$ matrix, then {\tt flatten x} is a $1\times mn$ matrix.
  Example
   R = ZZ/101[a,b,c];
   m = matrix {{2, a},{b^2, 23},{c, c^3}}
   flatten m
 Caveat
  The matrix produced by {\tt flatten m} is {\em not} the same as the
  matrix given by unnesting the list used to define the matrix.
 SeeAlso
  deepSplice
  splice
  "lists and sequences"
///