+Parentheses work again.
[lineal.git] / doc / crop.txt
blob6d428f244cad4852f2e4d3845eb6dcac1e67bc13
1 PREV: concatenating.txt                        NEXT: infix_specifics.txt
3 Cropping Structures
6 Intended for use with the |cat| function, crop can do some powerful
7 things. Crop accepts a number and the data structure from which you want
8 to crop.
10 Start by initializing some variables.
12 ------------------------------------------------------------------------
14  store("A", vcat(cat(3,5,7) cat(2,4,6) 2))
16                 (store "A" (vcat (cat 3 5 7) (cat 2 4 6) 2))
18       [3 5 7]
19  ==>  [2 4 6]
20       [2 2 2]
22 ------------------------------------------------------------------------
24  store("u", vcat(1,2,3))
26                 (store "u" (vcat 1 2 3))
28  ==>  (1, 2, 3)
30 ------------------------------------------------------------------------
32  crop(2,A)
33                 (crop 2 A)
35       [3 5]
36  ==>  [2 4]
37       [2 2]
39 Get the 2 left columns /A/.
41 ------------------------------------------------------------------------
43  vcrop(A,2)
44                 (vcrop A 2)
46       [3 5 7]
47  ==>  [2 4 6]
49 Get the bottom 2 rows of /A/.
51 ------------------------------------------------------------------------
53  crop(A,1)
54                 (crop A 1)
56  ==>  (7, 6, 2)
58 Only one column vector cropped from the right of /A/,
59 it is automatically transformed into a vector.
61 ------------------------------------------------------------------------
63  vcrop(1,u)
64                 (vcrop 1 u)
66  ==>  1
68 Like the previous example, only one element is cropped from vector /u/
69 so it is returned as a plain number.
71 NOTE: To get this effect, you must use vcrop instead of crop.
72    
73 ------------------------------------------------------------------------
75  vcrop(1,u)
76                 (vcrop 1 u)
78  ==>  (1, 2, 3)
80 Using crop on a vector just returns it.
82 ------------------------------------------------------------------------
83  vim:ft=:expandtab:tw=72: