<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <head> <title>Penlight Documentation</title> <link rel="stylesheet" href="../ldoc_fixed.css" type="text/css" /> </head> <body> <div id="container"> <div id="product"> <div id="product_logo"></div> <div id="product_name"><big><b></b></big></div> <div id="product_description"></div> </div> <!-- id="product" --> <div id="main"> <!-- Menu --> <div id="navigation"> <br/> <h1>Penlight</h1> <ul> <li><a href="../index.html">Index</a></li> </ul> <h2>Contents</h2> <ul> <li><a href="#Functions">Functions</a></li> </ul> <h2>Libraries</h2> <ul class="$(kind=='Topics' and '' or 'nowrap'"> <li><a href="../libraries/pl.html">pl</a></li> <li><a href="../libraries/pl.Set.html">pl.Set</a></li> <li><a href="../libraries/pl.app.html">pl.app</a></li> <li><strong>pl.array2d</strong></li> <li><a href="../libraries/pl.class.html">pl.class</a></li> <li><a href="../libraries/pl.compat.html">pl.compat</a></li> <li><a href="../libraries/pl.comprehension.html">pl.comprehension</a></li> <li><a href="../libraries/pl.config.html">pl.config</a></li> <li><a href="../libraries/pl.data.html">pl.data</a></li> <li><a href="../libraries/pl.dir.html">pl.dir</a></li> <li><a href="../libraries/pl.file.html">pl.file</a></li> <li><a href="../libraries/pl.func.html">pl.func</a></li> <li><a href="../libraries/pl.import_into.html">pl.import_into</a></li> <li><a href="../libraries/pl.input.html">pl.input</a></li> <li><a href="../libraries/pl.lapp.html">pl.lapp</a></li> <li><a href="../libraries/pl.lexer.html">pl.lexer</a></li> <li><a href="../libraries/pl.luabalanced.html">pl.luabalanced</a></li> <li><a href="../libraries/pl.operator.html">pl.operator</a></li> <li><a href="../libraries/pl.path.html">pl.path</a></li> <li><a href="../libraries/pl.permute.html">pl.permute</a></li> <li><a href="../libraries/pl.pretty.html">pl.pretty</a></li> <li><a href="../libraries/pl.seq.html">pl.seq</a></li> <li><a href="../libraries/pl.sip.html">pl.sip</a></li> <li><a href="../libraries/pl.strict.html">pl.strict</a></li> <li><a href="../libraries/pl.stringio.html">pl.stringio</a></li> <li><a href="../libraries/pl.stringx.html">pl.stringx</a></li> <li><a href="../libraries/pl.tablex.html">pl.tablex</a></li> <li><a href="../libraries/pl.template.html">pl.template</a></li> <li><a href="../libraries/pl.test.html">pl.test</a></li> <li><a href="../libraries/pl.text.html">pl.text</a></li> <li><a href="../libraries/pl.types.html">pl.types</a></li> <li><a href="../libraries/pl.url.html">pl.url</a></li> <li><a href="../libraries/pl.utils.html">pl.utils</a></li> <li><a href="../libraries/pl.xml.html">pl.xml</a></li> </ul> <h2>Classes</h2> <ul class="$(kind=='Topics' and '' or 'nowrap'"> <li><a href="../classes/pl.Date.html">pl.Date</a></li> <li><a href="../classes/pl.List.html">pl.List</a></li> <li><a href="../classes/pl.Map.html">pl.Map</a></li> <li><a href="../classes/pl.MultiMap.html">pl.MultiMap</a></li> <li><a href="../classes/pl.OrderedMap.html">pl.OrderedMap</a></li> </ul> <h2>Manual</h2> <ul class="$(kind=='Topics' and '' or 'nowrap'"> <li><a href="../manual/01-introduction.md.html">Introduction</a></li> <li><a href="../manual/02-arrays.md.html">Tables and Arrays</a></li> <li><a href="../manual/03-strings.md.html">Strings. Higher-level operations on strings.</a></li> <li><a href="../manual/04-paths.md.html">Paths and Directories</a></li> <li><a href="../manual/05-dates.md.html">Date and Time</a></li> <li><a href="../manual/06-data.md.html">Data</a></li> <li><a href="../manual/07-functional.md.html">Functional Programming</a></li> <li><a href="../manual/08-additional.md.html">Additional Libraries</a></li> <li><a href="../manual/09-discussion.md.html">Technical Choices</a></li> </ul> <h2>Examples</h2> <ul class="$(kind=='Topics' and '' or 'nowrap'"> <li><a href="../examples/seesubst.lua.html">seesubst.lua</a></li> <li><a href="../examples/sipscan.lua.html">sipscan.lua</a></li> <li><a href="../examples/symbols.lua.html">symbols.lua</a></li> <li><a href="../examples/test-cmp.lua.html">test-cmp.lua</a></li> <li><a href="../examples/test-data.lua.html">test-data.lua</a></li> <li><a href="../examples/test-listcallbacks.lua.html">test-listcallbacks.lua</a></li> <li><a href="../examples/test-pretty.lua.html">test-pretty.lua</a></li> <li><a href="../examples/test-symbols.lua.html">test-symbols.lua</a></li> <li><a href="../examples/testapp.lua.html">testapp.lua</a></li> <li><a href="../examples/testclone.lua.html">testclone.lua</a></li> <li><a href="../examples/testconfig.lua.html">testconfig.lua</a></li> <li><a href="../examples/testglobal.lua.html">testglobal.lua</a></li> <li><a href="../examples/testinputfields.lua.html">testinputfields.lua</a></li> <li><a href="../examples/testinputfields2.lua.html">testinputfields2.lua</a></li> <li><a href="../examples/testxml.lua.html">testxml.lua</a></li> <li><a href="../examples/which.lua.html">which.lua</a></li> </ul> </div> <div id="content"> <h1>Module <code>pl.array2d</code></h1> <p>Operations on two-dimensional arrays.</p> <p> See <a href="../manual/02-arrays.md.html#Operations_on_two_dimensional_tables">The Guide</a></p> <p> Dependencies: <a href="../libraries/pl.utils.html#">pl.utils</a>, <a href="../libraries/pl.tablex.html#">pl.tablex</a>, <a href="../libraries/pl.types.html#">pl.types</a></p> <h2><a href="#Functions">Functions</a></h2> <table class="function_list"> <tr> <td class="name" nowrap><a href="#size">size (t)</a></td> <td class="summary">return the row and column size.</td> </tr> <tr> <td class="name" nowrap><a href="#column">column (a, key)</a></td> <td class="summary">extract a column from the 2D array.</td> </tr> <tr> <td class="name" nowrap><a href="#map">map (f, a, arg)</a></td> <td class="summary">map a function over a 2D array</td> </tr> <tr> <td class="name" nowrap><a href="#reduce_rows">reduce_rows (f, a)</a></td> <td class="summary">reduce the rows using a function.</td> </tr> <tr> <td class="name" nowrap><a href="#reduce_cols">reduce_cols (f, a)</a></td> <td class="summary">reduce the columns using a function.</td> </tr> <tr> <td class="name" nowrap><a href="#reduce2">reduce2 (opc, opr, a)</a></td> <td class="summary">reduce a 2D array into a scalar, using two operations.</td> </tr> <tr> <td class="name" nowrap><a href="#map2">map2 (f, ad, bd, a, b, arg)</a></td> <td class="summary">map a function over two arrays.</td> </tr> <tr> <td class="name" nowrap><a href="#product">product (f, t1, t2)</a></td> <td class="summary">cartesian product of two 1d arrays.</td> </tr> <tr> <td class="name" nowrap><a href="#flatten">flatten (t)</a></td> <td class="summary">flatten a 2D array.</td> </tr> <tr> <td class="name" nowrap><a href="#reshape">reshape (t, nrows, co)</a></td> <td class="summary">reshape a 2D array.</td> </tr> <tr> <td class="name" nowrap><a href="#swap_rows">swap_rows (t, i1, i2)</a></td> <td class="summary">swap two rows of an array.</td> </tr> <tr> <td class="name" nowrap><a href="#swap_cols">swap_cols (t, j1, j2)</a></td> <td class="summary">swap two columns of an array.</td> </tr> <tr> <td class="name" nowrap><a href="#extract_rows">extract_rows (t, ridx)</a></td> <td class="summary">extract the specified rows.</td> </tr> <tr> <td class="name" nowrap><a href="#extract_cols">extract_cols (t, cidx)</a></td> <td class="summary">extract the specified columns.</td> </tr> <tr> <td class="name" nowrap><a href="#remove_row">remove_row (t, i)</a></td> <td class="summary">remove a row from an array.</td> </tr> <tr> <td class="name" nowrap><a href="#remove_col">remove_col (t, j)</a></td> <td class="summary">remove a column from an array.</td> </tr> <tr> <td class="name" nowrap><a href="#parse_range">parse_range (s)</a></td> <td class="summary">parse a spreadsheet range.</td> </tr> <tr> <td class="name" nowrap><a href="#range">range (t, rstr)</a></td> <td class="summary">get a slice of a 2D array using spreadsheet range notation.</td> </tr> <tr> <td class="name" nowrap><a href="#slice">slice (t, i1, j1, i2, j2)</a></td> <td class="summary">get a slice of a 2D array.</td> </tr> <tr> <td class="name" nowrap><a href="#set">set (t, value, i1, j1, i2, j2)</a></td> <td class="summary">set a specified range of an array to a value.</td> </tr> <tr> <td class="name" nowrap><a href="#write">write (t, f, fmt, i1, j1, i2, j2)</a></td> <td class="summary">write a 2D array to a file.</td> </tr> <tr> <td class="name" nowrap><a href="#forall">forall (t, row_op, end_row_op, i1, j1, i2, j2)</a></td> <td class="summary">perform an operation for all values in a 2D array.</td> </tr> <tr> <td class="name" nowrap><a href="#move">move (dest, di, dj, src, i1, j1, i2, j2)</a></td> <td class="summary">move a block from the destination to the source.</td> </tr> <tr> <td class="name" nowrap><a href="#iter">iter (a, indices, i1, j1, i2, j2)</a></td> <td class="summary">iterate over all elements in a 2D array, with optional indices.</td> </tr> <tr> <td class="name" nowrap><a href="#columns">columns (a)</a></td> <td class="summary">iterate over all columns.</td> </tr> <tr> <td class="name" nowrap><a href="#new">new (rows, cols, val)</a></td> <td class="summary">new array of specified dimensions</td> </tr> </table> <br/> <br/> <h2><a name="Functions"></a>Functions</h2> <dl class="function"> <dt> <a name = "size"></a> <strong>size (t)</strong> </dt> <dd> return the row and column size. <h3>Parameters:</h3> <ul> <li><span class="parameter">t</span> <span class="types"><span class="type">array</span></span> a 2d array </li> </ul> <h3>Returns:</h3> <ol> <li> <span class="types"><span class="type">int</span></span> number of rows</li> <li> <span class="types"><span class="type">int</span></span> number of cols</li> </ol> </dd> <dt> <a name = "column"></a> <strong>column (a, key)</strong> </dt> <dd> extract a column from the 2D array. <h3>Parameters:</h3> <ul> <li><span class="parameter">a</span> <span class="types"><span class="type">array</span></span> 2d array </li> <li><span class="parameter">key</span> an index or key </li> </ul> <h3>Returns:</h3> <ol> 1d array </ol> </dd> <dt> <a name = "map"></a> <strong>map (f, a, arg)</strong> </dt> <dd> map a function over a 2D array <h3>Parameters:</h3> <ul> <li><span class="parameter">f</span> <span class="types"><span class="type">func</span></span> a function of at least one argument </li> <li><span class="parameter">a</span> <span class="types"><span class="type">array</span></span> 2d array </li> <li><span class="parameter">arg</span> an optional extra argument to be passed to the function. </li> </ul> <h3>Returns:</h3> <ol> 2d array </ol> </dd> <dt> <a name = "reduce_rows"></a> <strong>reduce_rows (f, a)</strong> </dt> <dd> reduce the rows using a function. <h3>Parameters:</h3> <ul> <li><span class="parameter">f</span> <span class="types"><span class="type">func</span></span> a binary function </li> <li><span class="parameter">a</span> <span class="types"><span class="type">array</span></span> 2d array </li> </ul> <h3>Returns:</h3> <ol> 1d array </ol> <h3>See also:</h3> <ul> <a href="../libraries/pl.tablex.html#reduce">pl.tablex.reduce</a> </ul> </dd> <dt> <a name = "reduce_cols"></a> <strong>reduce_cols (f, a)</strong> </dt> <dd> reduce the columns using a function. <h3>Parameters:</h3> <ul> <li><span class="parameter">f</span> <span class="types"><span class="type">func</span></span> a binary function </li> <li><span class="parameter">a</span> <span class="types"><span class="type">array</span></span> 2d array </li> </ul> <h3>Returns:</h3> <ol> 1d array </ol> <h3>See also:</h3> <ul> <a href="../libraries/pl.tablex.html#reduce">pl.tablex.reduce</a> </ul> </dd> <dt> <a name = "reduce2"></a> <strong>reduce2 (opc, opr, a)</strong> </dt> <dd> reduce a 2D array into a scalar, using two operations. <h3>Parameters:</h3> <ul> <li><span class="parameter">opc</span> <span class="types"><span class="type">func</span></span> operation to reduce the final result </li> <li><span class="parameter">opr</span> <span class="types"><span class="type">func</span></span> operation to reduce the rows </li> <li><span class="parameter">a</span> 2D array </li> </ul> </dd> <dt> <a name = "map2"></a> <strong>map2 (f, ad, bd, a, b, arg)</strong> </dt> <dd> map a function over two arrays. They can be both or either 2D arrays <h3>Parameters:</h3> <ul> <li><span class="parameter">f</span> <span class="types"><span class="type">func</span></span> function of at least two arguments </li> <li><span class="parameter">ad</span> <span class="types"><span class="type">int</span></span> order of first array (1 or 2) </li> <li><span class="parameter">bd</span> <span class="types"><span class="type">int</span></span> order of second array (1 or 2) </li> <li><span class="parameter">a</span> <span class="types"><span class="type">tab</span></span> 1d or 2d array </li> <li><span class="parameter">b</span> <span class="types"><span class="type">tab</span></span> 1d or 2d array </li> <li><span class="parameter">arg</span> optional extra argument to pass to function </li> </ul> <h3>Returns:</h3> <ol> 2D array, unless both arrays are 1D </ol> </dd> <dt> <a name = "product"></a> <strong>product (f, t1, t2)</strong> </dt> <dd> cartesian product of two 1d arrays. <h3>Parameters:</h3> <ul> <li><span class="parameter">f</span> <span class="types"><span class="type">func</span></span> a function of 2 arguments </li> <li><span class="parameter">t1</span> <span class="types"><span class="type">array</span></span> a 1d table </li> <li><span class="parameter">t2</span> <span class="types"><span class="type">array</span></span> a 1d table </li> </ul> <h3>Returns:</h3> <ol> 2d table </ol> <h3>Usage:</h3> <ul> <pre class="example">product(<span class="string">'..'</span>,{<span class="number">1</span>,<span class="number">2</span>},{<span class="string">'a'</span>,<span class="string">'b'</span>}) == {{<span class="string">'1a'</span>,<span class="string">'2a'</span>},{<span class="string">'1b'</span>,<span class="string">'2b'</span>}}</pre> </ul> </dd> <dt> <a name = "flatten"></a> <strong>flatten (t)</strong> </dt> <dd> flatten a 2D array. (this goes over columns first.) <h3>Parameters:</h3> <ul> <li><span class="parameter">t</span> <span class="types"><span class="type">array</span></span> 2d table </li> </ul> <h3>Returns:</h3> <ol> a 1d table </ol> <h3>Usage:</h3> <ul> <pre class="example">flatten {{<span class="number">1</span>,<span class="number">2</span>},{<span class="number">3</span>,<span class="number">4</span>},{<span class="number">5</span>,<span class="number">6</span>}} == {<span class="number">1</span>,<span class="number">2</span>,<span class="number">3</span>,<span class="number">4</span>,<span class="number">5</span>,<span class="number">6</span>}</pre> </ul> </dd> <dt> <a name = "reshape"></a> <strong>reshape (t, nrows, co)</strong> </dt> <dd> reshape a 2D array. <h3>Parameters:</h3> <ul> <li><span class="parameter">t</span> <span class="types"><span class="type">array</span></span> 2d array </li> <li><span class="parameter">nrows</span> <span class="types"><span class="type">int</span></span> new number of rows </li> <li><span class="parameter">co</span> <span class="types"><span class="type">bool</span></span> column-order (Fortran-style) (default false) </li> </ul> <h3>Returns:</h3> <ol> a new 2d array </ol> </dd> <dt> <a name = "swap_rows"></a> <strong>swap_rows (t, i1, i2)</strong> </dt> <dd> swap two rows of an array. <h3>Parameters:</h3> <ul> <li><span class="parameter">t</span> <span class="types"><span class="type">array</span></span> a 2d array </li> <li><span class="parameter">i1</span> <span class="types"><span class="type">int</span></span> a row index </li> <li><span class="parameter">i2</span> <span class="types"><span class="type">int</span></span> a row index </li> </ul> </dd> <dt> <a name = "swap_cols"></a> <strong>swap_cols (t, j1, j2)</strong> </dt> <dd> swap two columns of an array. <h3>Parameters:</h3> <ul> <li><span class="parameter">t</span> <span class="types"><span class="type">array</span></span> a 2d array </li> <li><span class="parameter">j1</span> <span class="types"><span class="type">int</span></span> a column index </li> <li><span class="parameter">j2</span> <span class="types"><span class="type">int</span></span> a column index </li> </ul> </dd> <dt> <a name = "extract_rows"></a> <strong>extract_rows (t, ridx)</strong> </dt> <dd> extract the specified rows. <h3>Parameters:</h3> <ul> <li><span class="parameter">t</span> <span class="types"><span class="type">array</span></span> 2d array </li> <li><span class="parameter">ridx</span> <span class="types"><span class="type">{int}</span></span> a table of row indices </li> </ul> </dd> <dt> <a name = "extract_cols"></a> <strong>extract_cols (t, cidx)</strong> </dt> <dd> extract the specified columns. <h3>Parameters:</h3> <ul> <li><span class="parameter">t</span> <span class="types"><span class="type">array</span></span> 2d array </li> <li><span class="parameter">cidx</span> <span class="types"><span class="type">{int}</span></span> a table of column indices </li> </ul> </dd> <dt> <a name = "remove_row"></a> <strong>remove_row (t, i)</strong> </dt> <dd> remove a row from an array. <h3>Parameters:</h3> <ul> <li><span class="parameter">t</span> <span class="types"><span class="type">array</span></span> a 2d array </li> <li><span class="parameter">i</span> <span class="types"><span class="type">int</span></span> a row index </li> </ul> </dd> <dt> <a name = "remove_col"></a> <strong>remove_col (t, j)</strong> </dt> <dd> remove a column from an array. <h3>Parameters:</h3> <ul> <li><span class="parameter">t</span> <span class="types"><span class="type">array</span></span> a 2d array </li> <li><span class="parameter">j</span> <span class="types"><span class="type">int</span></span> a column index </li> </ul> </dd> <dt> <a name = "parse_range"></a> <strong>parse_range (s)</strong> </dt> <dd> parse a spreadsheet range. The range can be specified either as 'A1:B2' or 'R1C1:R2C2'; a special case is a single element (e.g 'A1' or 'R1C1') <h3>Parameters:</h3> <ul> <li><span class="parameter">s</span> <span class="types"><a class="type" href="http://www.lua.org/manual/5.2/manual.html#6.4">string</a></span> a range. </li> </ul> <h3>Returns:</h3> <ol> <li> <span class="types"><span class="type">int</span></span> start col</li> <li> <span class="types"><span class="type">int</span></span> start row</li> <li> <span class="types"><span class="type">int</span></span> end col</li> <li> <span class="types"><span class="type">int</span></span> end row</li> </ol> </dd> <dt> <a name = "range"></a> <strong>range (t, rstr)</strong> </dt> <dd> get a slice of a 2D array using spreadsheet range notation. @see parse_range <h3>Parameters:</h3> <ul> <li><span class="parameter">t</span> <span class="types"><span class="type">array</span></span> a 2D array </li> <li><span class="parameter">rstr</span> <span class="types"><a class="type" href="http://www.lua.org/manual/5.2/manual.html#6.4">string</a></span> range expression </li> </ul> <h3>Returns:</h3> <ol> a slice </ol> <h3>See also:</h3> <ul> <li><a href="../libraries/pl.array2d.html#parse_range">array2d.parse_range</a></li> <li><a href="../libraries/pl.array2d.html#slice">array2d.slice</a></li> </ul> </dd> <dt> <a name = "slice"></a> <strong>slice (t, i1, j1, i2, j2)</strong> </dt> <dd> get a slice of a 2D array. Note that if the specified range has a 1D result, the rank of the result will be 1. <h3>Parameters:</h3> <ul> <li><span class="parameter">t</span> <span class="types"><span class="type">array</span></span> a 2D array </li> <li><span class="parameter">i1</span> <span class="types"><span class="type">int</span></span> start row (default 1) </li> <li><span class="parameter">j1</span> <span class="types"><span class="type">int</span></span> start col (default 1) </li> <li><span class="parameter">i2</span> <span class="types"><span class="type">int</span></span> end row (default N) </li> <li><span class="parameter">j2</span> <span class="types"><span class="type">int</span></span> end col (default M) </li> </ul> <h3>Returns:</h3> <ol> an array, 2D in general but 1D in special cases. </ol> </dd> <dt> <a name = "set"></a> <strong>set (t, value, i1, j1, i2, j2)</strong> </dt> <dd> set a specified range of an array to a value. <h3>Parameters:</h3> <ul> <li><span class="parameter">t</span> <span class="types"><span class="type">array</span></span> a 2D array </li> <li><span class="parameter">value</span> the value (may be a function) </li> <li><span class="parameter">i1</span> <span class="types"><span class="type">int</span></span> start row (default 1) </li> <li><span class="parameter">j1</span> <span class="types"><span class="type">int</span></span> start col (default 1) </li> <li><span class="parameter">i2</span> <span class="types"><span class="type">int</span></span> end row (default N) </li> <li><span class="parameter">j2</span> <span class="types"><span class="type">int</span></span> end col (default M) </li> </ul> <h3>See also:</h3> <ul> <a href="../libraries/pl.tablex.html#set">tablex.set</a> </ul> </dd> <dt> <a name = "write"></a> <strong>write (t, f, fmt, i1, j1, i2, j2)</strong> </dt> <dd> write a 2D array to a file. <h3>Parameters:</h3> <ul> <li><span class="parameter">t</span> <span class="types"><span class="type">array</span></span> a 2D array </li> <li><span class="parameter">f</span> a file object (default stdout) </li> <li><span class="parameter">fmt</span> <span class="types"><a class="type" href="http://www.lua.org/manual/5.2/manual.html#6.4">string</a></span> a format string (default is just to use tostring) </li> <li><span class="parameter">i1</span> <span class="types"><span class="type">int</span></span> start row (default 1) </li> <li><span class="parameter">j1</span> <span class="types"><span class="type">int</span></span> start col (default 1) </li> <li><span class="parameter">i2</span> <span class="types"><span class="type">int</span></span> end row (default N) </li> <li><span class="parameter">j2</span> <span class="types"><span class="type">int</span></span> end col (default M) </li> </ul> </dd> <dt> <a name = "forall"></a> <strong>forall (t, row_op, end_row_op, i1, j1, i2, j2)</strong> </dt> <dd> perform an operation for all values in a 2D array. <h3>Parameters:</h3> <ul> <li><span class="parameter">t</span> <span class="types"><span class="type">array</span></span> 2D array </li> <li><span class="parameter">row_op</span> <span class="types"><span class="type">func</span></span> function to call on each value </li> <li><span class="parameter">end_row_op</span> <span class="types"><span class="type">func</span></span> function to call at end of each row </li> <li><span class="parameter">i1</span> <span class="types"><span class="type">int</span></span> start row (default 1) </li> <li><span class="parameter">j1</span> <span class="types"><span class="type">int</span></span> start col (default 1) </li> <li><span class="parameter">i2</span> <span class="types"><span class="type">int</span></span> end row (default N) </li> <li><span class="parameter">j2</span> <span class="types"><span class="type">int</span></span> end col (default M) </li> </ul> </dd> <dt> <a name = "move"></a> <strong>move (dest, di, dj, src, i1, j1, i2, j2)</strong> </dt> <dd> move a block from the destination to the source. <h3>Parameters:</h3> <ul> <li><span class="parameter">dest</span> <span class="types"><span class="type">array</span></span> a 2D array </li> <li><span class="parameter">di</span> <span class="types"><span class="type">int</span></span> start row in dest </li> <li><span class="parameter">dj</span> <span class="types"><span class="type">int</span></span> start col in dest </li> <li><span class="parameter">src</span> <span class="types"><span class="type">array</span></span> a 2D array </li> <li><span class="parameter">i1</span> <span class="types"><span class="type">int</span></span> start row (default 1) </li> <li><span class="parameter">j1</span> <span class="types"><span class="type">int</span></span> start col (default 1) </li> <li><span class="parameter">i2</span> <span class="types"><span class="type">int</span></span> end row (default N) </li> <li><span class="parameter">j2</span> <span class="types"><span class="type">int</span></span> end col (default M) </li> </ul> </dd> <dt> <a name = "iter"></a> <strong>iter (a, indices, i1, j1, i2, j2)</strong> </dt> <dd> iterate over all elements in a 2D array, with optional indices. <h3>Parameters:</h3> <ul> <li><span class="parameter">a</span> <span class="types"><span class="type">array</span></span> 2D array </li> <li><span class="parameter">indices</span> <span class="types"><span class="type">{int}</span></span> with indices (default false) </li> <li><span class="parameter">i1</span> <span class="types"><span class="type">int</span></span> start row (default 1) </li> <li><span class="parameter">j1</span> <span class="types"><span class="type">int</span></span> start col (default 1) </li> <li><span class="parameter">i2</span> <span class="types"><span class="type">int</span></span> end row (default N) </li> <li><span class="parameter">j2</span> <span class="types"><span class="type">int</span></span> end col (default M) </li> </ul> <h3>Returns:</h3> <ol> either value or i,j,value depending on indices </ol> </dd> <dt> <a name = "columns"></a> <strong>columns (a)</strong> </dt> <dd> iterate over all columns. <h3>Parameters:</h3> <ul> <li><span class="parameter">a</span> <span class="types"><span class="type">array</span></span> a 2D array </li> </ul> <h3>Returns:</h3> <ol> each column in turn </ol> </dd> <dt> <a name = "new"></a> <strong>new (rows, cols, val)</strong> </dt> <dd> new array of specified dimensions <h3>Parameters:</h3> <ul> <li><span class="parameter">rows</span> <span class="types"><span class="type">int</span></span> number of rows </li> <li><span class="parameter">cols</span> <span class="types"><span class="type">int</span></span> number of cols </li> <li><span class="parameter">val</span> initial value; if it's a function then use <code>val(i,j)</code> </li> </ul> <h3>Returns:</h3> <ol> new 2d array </ol> </dd> </dl> </div> <!-- id="content" --> </div> <!-- id="main" --> <div id="about"> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.3</a></i> <i style="float:right;">Last updated 2015-03-21 18:49:03 </i> </div> <!-- id="about" --> </div> <!-- id="container" --> </body> </html>