| 1 |
<html><head><meta name="robots" content="index,follow"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
| 2 |
<title>part##</title> |
| 3 |
<style> |
| 4 |
td { padding-left: 5pt; padding-right: 5pt; } |
| 5 |
th { padding-left: 5pt; padding-right: 5pt; } |
| 6 |
code { white-space: pre-wrap; } |
| 7 |
dd { white-space: pre-wrap; } |
| 8 |
</style> |
| 9 |
</head><body bgcolor="#FFFFFF"> |
| 10 |
|
| 11 |
<table border=0 cellpadding=0 cellspacing=0><tr><td bgcolor="#CCCC00"><table border=4 cellpadding=9><tr><td align=middle bgcolor="#000000"><font face="Monaco,Courier" size=6 color="#999900"><b> |
| 12 |
part## |
| 13 |
</b></font></table></table> |
| 14 |
<p>A function that can be used in <a href="Formulas.html">Formulas</a>.</p> |
| 15 |
<h2>Syntax and semantics</h2> |
| 16 |
<dl> |
| 17 |
<dt><b><code><font size=+1>part##</font></code></b> (<i><code><font size=+1>matrix#</font></code></i>, <i><code><font size=+1>fromRow</font></code></i>, <i><code><font size=+1>toRow</font></code></i>, <i><code><font size=+1>fromColumn</font></code></i>, <i><code><font size=+1>toColumn</font></code></i>) |
| 18 |
<dd>compute a subwindow of cells of a matrix.</dd> |
| 19 |
</dl> |
| 20 |
<h2>Examples</h2> |
| 21 |
<code> <a href="_assert_.html">assert</a> part## ({{ 7, 4, 9, 3 }, { 1, 4, 3, 22 }, { 0, 8, 6, 5 }},<br></code> |
| 22 |
<code> ... 2, 3, 1, 3) = {{ 1, 4, 3 }, { 0, 8, 6 }}<br></code> |
| 23 |
<h2>Examples of error messages</h2> |
| 24 |
<p>Checks on the number of arguments (always has to be 5):</p> |
| 25 |
<code> asserterror The function “part##” requires exactly five arguments<br></code> |
| 26 |
<code> ... (namely a matrix, a starting row, an end row, a starting column, and an end column),<br></code> |
| 27 |
<code> ... not the 0 given.<br></code> |
| 28 |
<code> a## = part## ()<br></code> |
| 29 |
<code> <br></code> |
| 30 |
<code> asserterror The function “part##” requires exactly five arguments<br></code> |
| 31 |
<code> ... (namely a matrix, a starting row, an end row, a starting column, and an end column),<br></code> |
| 32 |
<code> ... not the 7 given.<br></code> |
| 33 |
<code> a## = part## (7, 8, 9, 10, 11, "hello", "world")<br></code> |
| 34 |
<p>Checks on the types of the arguments (always has to be matrix, number, number, number, number):</p> |
| 35 |
<code> asserterror The first argument of the function “part##” should be<br></code> |
| 36 |
<code> ... a numeric matrix, not a number.<br></code> |
| 37 |
<code> a## = part## (2, 4, { 5, 6, 7, 9, 8 }, 66, 99)<br></code> |
| 38 |
<code> <br></code> |
| 39 |
<code> asserterror The first argument of the function “part##” should be<br></code> |
| 40 |
<code> ... a numeric matrix, not a string.<br></code> |
| 41 |
<code> a## = part## ("hello", 4, { 5, 6, 7, 9, 8 }, 66, 99)<br></code> |
| 42 |
<code> <br></code> |
| 43 |
<code> asserterror The first argument of the function “part##” should be<br></code> |
| 44 |
<code> ... a numeric matrix, not a numeric vector.<br></code> |
| 45 |
<code> a## = part## ({ 5, 6, 7, 9, 8 }, 4, { 5, 6, 7, 9, 8 }, 66, 99)<br></code> |
| 46 |
<code> <br></code> |
| 47 |
<code> m## = {{ 7, 4, 9, 3 }, { 1, 4, 3, 22 }, { 0, 8, 6, 5 }} ; three rows, four columns<br></code> |
| 48 |
<code> <br></code> |
| 49 |
<code> asserterror The second argument of the function “part##” should be<br></code> |
| 50 |
<code> ... a number (the starting row), not a string.<br></code> |
| 51 |
<code> a## = part## (m##, "hello", 4, 66, 99)<br></code> |
| 52 |
<code> <br></code> |
| 53 |
<code> asserterror The second argument of the function “part##” should be<br></code> |
| 54 |
<code> ... a number (the starting row), not a numeric vector.<br></code> |
| 55 |
<code> a## = part## (m##, { 0 }, 4, 66, 99)<br></code> |
| 56 |
<code> <br></code> |
| 57 |
<code> asserterror The third argument of the function “part##” should be<br></code> |
| 58 |
<code> ... a number (the end row), not a string.<br></code> |
| 59 |
<code> a## = part## (m##, 4, "hello", 66, 99)<br></code> |
| 60 |
<code> <br></code> |
| 61 |
<code> asserterror The third argument of the function “part##” should be<br></code> |
| 62 |
<code> ... a number (the end row), not a numeric vector.<br></code> |
| 63 |
<code> a## = part## (m##, 4, { 0 }, 66, 99)<br></code> |
| 64 |
<code> <br></code> |
| 65 |
<code> asserterror The fourth argument of the function “part##” should be<br></code> |
| 66 |
<code> ... a number (the starting column), not a string.<br></code> |
| 67 |
<code> a## = part## (m##, 66, 99, "hello", 4)<br></code> |
| 68 |
<code> <br></code> |
| 69 |
<code> asserterror The fourth argument of the function “part##” should be<br></code> |
| 70 |
<code> ... a number (the starting column), not a numeric vector.<br></code> |
| 71 |
<code> a## = part## (m##, 66, 99, { 0 }, 4)<br></code> |
| 72 |
<code> <br></code> |
| 73 |
<code> asserterror The fifth argument of the function “part##” should be<br></code> |
| 74 |
<code> ... a number (the end column), not a string.<br></code> |
| 75 |
<code> a## = part## (m##, 66, 99, 4, "hello")<br></code> |
| 76 |
<code> <br></code> |
| 77 |
<code> asserterror The fifth argument of the function “part##” should be<br></code> |
| 78 |
<code> ... a number (the end column), not a numeric vector.<br></code> |
| 79 |
<code> a## = part## (m##, 66, 99, 4, { 0 })<br></code> |
| 80 |
<p>Finally the checks on the preconditions of the arguments: both row numbers and both column numbers should be within bounds:</p> |
| 81 |
<code> asserterror The second argument of the function “part##” (the starting row)<br></code> |
| 82 |
<code> ... should (after rounding) be a positive whole number, not -3.<br></code> |
| 83 |
<code> a## = part## (m##, -2.98, 0, 66, 99)<br></code> |
| 84 |
<code> <br></code> |
| 85 |
<code> asserterror The second argument of the function “part##” (the starting row)<br></code> |
| 86 |
<code> ... should (after rounding) be a positive whole number, not 0.<br></code> |
| 87 |
<code> a## = part## (m##, 0, 0, 66, 99)<br></code> |
| 88 |
<code> <br></code> |
| 89 |
<code> asserterror The second argument of the function “part##” (the starting row)<br></code> |
| 90 |
<code> ... should (after rounding) be at most the number of rows (3), not 99.<br></code> |
| 91 |
<code> a## = part## (m##, 99, 0, 66, 99)<br></code> |
| 92 |
<code> <br></code> |
| 93 |
<code> asserterror The second argument of the function “part##” (the starting row)<br></code> |
| 94 |
<code> ... should (after rounding) be at most the number of rows (3), not 4.<br></code> |
| 95 |
<code> a## = part## (m##, 3.5, 0, 66, 99)<br></code> |
| 96 |
<code> <br></code> |
| 97 |
<code> asserterror The third argument of the function “part##” (the end row)<br></code> |
| 98 |
<code> ... should (after rounding) be a positive whole number, not -3.<br></code> |
| 99 |
<code> a## = part## (m##, 2, -2.98, 66, 99)<br></code> |
| 100 |
<code> <br></code> |
| 101 |
<code> asserterror The third argument of the function “part##” (the end row)<br></code> |
| 102 |
<code> ... should (after rounding) be a positive whole number, not 0.<br></code> |
| 103 |
<code> a## = part## (m##, 2, 0, 66, 99)<br></code> |
| 104 |
<code> <br></code> |
| 105 |
<code> asserterror The third argument of the function “part##” (the end row)<br></code> |
| 106 |
<code> ... should (after rounding) be at most the number of rows (3), not 99.<br></code> |
| 107 |
<code> a## = part## (m##, 2, 99, 66, 99)<br></code> |
| 108 |
<code> <br></code> |
| 109 |
<code> asserterror The third argument of the function “part##” (the end row)<br></code> |
| 110 |
<code> ... should (after rounding) be at most the number of rows (3), not 4.<br></code> |
| 111 |
<code> a## = part## (m##, 2, 3.5, 66, 99)<br></code> |
| 112 |
<code> <br></code> |
| 113 |
<code> asserterror The fourth argument of the function “part##” (the starting column)<br></code> |
| 114 |
<code> ... should (after rounding) be a positive whole number, not -3.<br></code> |
| 115 |
<code> a## = part## (m##, 2, 3, -2.98, 0)<br></code> |
| 116 |
<code> <br></code> |
| 117 |
<code> asserterror The fourth argument of the function “part##” (the starting column)<br></code> |
| 118 |
<code> ... should (after rounding) be a positive whole number, not 0.<br></code> |
| 119 |
<code> a## = part## (m##, 2, 3, 0, 0)<br></code> |
| 120 |
<code> <br></code> |
| 121 |
<code> asserterror The fourth argument of the function “part##” (the starting column)<br></code> |
| 122 |
<code> ... should (after rounding) be at most the number of columns (4), not 99.<br></code> |
| 123 |
<code> a## = part## (m##, 2, 3, 99, 0)<br></code> |
| 124 |
<code> <br></code> |
| 125 |
<code> asserterror The fourth argument of the function “part##” (the starting column)<br></code> |
| 126 |
<code> ... should (after rounding) be at most the number of columns (4), not 5.<br></code> |
| 127 |
<code> a## = part## (m##, 2, 3, 4.5, 0)<br></code> |
| 128 |
<code> <br></code> |
| 129 |
<code> asserterror The fifth argument of the function “part##” (the end column)<br></code> |
| 130 |
<code> ... should (after rounding) be a positive whole number, not -3.<br></code> |
| 131 |
<code> a## = part## (m##, 2, 3, 1, -2.98)<br></code> |
| 132 |
<code> <br></code> |
| 133 |
<code> asserterror The fifth argument of the function “part##” (the end column)<br></code> |
| 134 |
<code> ... should (after rounding) be a positive whole number, not 0.<br></code> |
| 135 |
<code> a## = part## (m##, 2, 3, 1, 0)<br></code> |
| 136 |
<code> <br></code> |
| 137 |
<code> asserterror The fifth argument of the function “part##” (the end column)<br></code> |
| 138 |
<code> ... should (after rounding) be at most the number of columns (4), not 99.<br></code> |
| 139 |
<code> a## = part## (m##, 2, 3, 1, 99)<br></code> |
| 140 |
<code> <br></code> |
| 141 |
<code> asserterror The fifth argument of the function “part##” (the end column)<br></code> |
| 142 |
<code> ... should (after rounding) be at most the number of columns (4), not 5.<br></code> |
| 143 |
<code> a## = part## (m##, 2, 3, 1, 4.5)<br></code> |
| 144 |
<h3>Links to this page</h3> |
| 145 |
<ul> |
| 146 |
<li><a href="What_was_new_in_6_4_.html">What was new in 6.4?</a> |
| 147 |
</ul> |
| 148 |
<hr> |
| 149 |
<address> |
| 150 |
<p>© Paul Boersma 2023</p> |
| 151 |
</address> |
| 152 |
</body> |
| 153 |
</html> |