File: mingle-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 (51 lines) | stat: -rw-r--r-- 1,320 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
42
43
44
45
46
47
48
49
50
51
-- Status: rewritten July 2018
-- Author: Lily Silverstein

doc///
 Key
  mingle
  (mingle, BasicList)
 Headline
  mingle elements of several lists
 Usage
  mingle(L)
 Inputs
  L:BasicList
   a list of lists {\tt L=\{L1, L2, ..., Ln\}}
 Outputs
  M:List
   a new list mingling the elements of all lists in {\tt L}
 Description
  Text
   The output list {\tt M} takes the first element of each {\tt Li, i=1,...,n}, followed by
   the second element of {\tt Li, i=1,...,n}, and so forth.  
  Example
   mingle {{a1, a2, a3}, {b1, b2, b3}, {c1, c2, c3}}
  Text
   The lists can have different lengths. After a list is exhausted, it
   will be silently ignored.
  Example
   mingle {{a1, a2, a3, a4}, {b1, b2}, {c1}}
  Text
   To transpose a nested list (thinking of it as a matrix), try
   using {\tt mingle} with @TO pack@.
  Example
   pack(3, mingle ((a1, a2, a3), (b1, b2, b3), (c1, c2, c3)))
  Text
   Notice from the previous example that {\tt mingle} accepts sequences and
   other types of @TO BasicList@s as input, but the output will always be a 
   @TO List@. 
  Text
   Further examples:
  Example
   concatenate mingle( {"a","b","c"} , {",",","} )
   netList pack(3, mingle( (0..5), apply(6, i -> i^2), apply(6, i -> i^3)))
 SeeAlso
  apply
  insert
  join
  pack
  sort
  sublists
  "lists and sequences"
///