i1 = t = (3,4,5)
o1 = 3,4,5
o1 : Sequence
i2 = # t
o2 = 3
Sequences of length zero and one cannot be created with commas, so there are special constructions. for them. Use seq to create a sequence of length one, and () to create a sequence of length zero.
i3 = u = ()
o3 =
o3 : Sequence
i4 = # u
o4 = 0
i5 = v = seq 45
o5 = seq 45
o5 : Sequence
i6 = # v
o6 = 1
A list is created by surrounding a sequence with braces. Use {} to create a list of length zero. The class of all lists is List.
i7 = w = {3,4,5}
o7 = {3,4,5}
o7 : List
i8 = # w
o8 = 3
i9 = # {}
o9 = 0
i10 = x = {(3,4,5)}
o10 = {(3,4,5)}
o10 : List
i11 = # x
o11 = 1
i12 = y = {(3,4,5),7}
o12 = {(3,4,5),7}
o12 : List
i13 = # y
o13 = 2
Lists can be used as vectors.
i14 = 2*{3,4,5} - {0,0,1}
o14 = {6,8,9}
o14 : List
A table is a list of lists of the same length. The inner lists
are regarded as rows when the table is displayed two-dimensionally.
i15 = z = {{a,1},{b,2},{c,3}}
o15 = {{a,1},{b,2},{c,3}}
o15 : List
i16 = new MatrixExpression from z
o16 = | a 1 |
| |
| b 2 |
| |
| c 3 |
o16 : MatrixExpression
An array is created by surrounding a sequence with brackets. Use [] to create a list of length zero. An array is a type of basic list, which means that the class Array of all arrays has BasicList as its parent.
i17 = f = [3,4,5]
o17 = [3,4,5]
o17 : Array
i18 = class f
o18 = Array
o18 : Type
Array -- the class of all arrays.
i19 = parent class f
o19 = BasicList
o19 : Type
BasicList -- the class of all things represented internally as a
list. A list is a sequence of expressions indexed by integers
0, 1, ..., N-1, where N is the length of the sequence.
Omitting an element of a sequence, list, or array, causes the
non-printing symbol null to be inserted in its place.
i20 = g = (3,4,,5)
o20 = 3,4,null,5
o20 : Sequence
i21 = g#2
i22 = (3,4,,5) == (3,4,null,5)
o22 = true
One calls functions with the notation f(x,y,z); here you may think of x, y, and z as the three arguments to f, or you may regard the sequence (x,y,z) as the single argument of f. For the former, one takes a function f of the form
(a,b,c) -> ...For the latter, one takes f of the form
t -> ...Types of list:
Creating new lists or sequences:
Selecting elements of lists:
Manipulating lists:
Examining lists:
Combining lists:
Mapping functions:
Go to main index.
Go to concepts index.