449 lines
24 KiB
HTML
449 lines
24 KiB
HTML
<?xml version="1.0" encoding="iso-8859-1" ?>
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
<!--http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd-->
|
|
<html xmlns="http://www.w3.org/1999/xhtml"
|
|
>
|
|
<head><title>19 Data.Ix</title>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
|
<meta name="generator" content="TeX4ht (http://www.cse.ohio-state.edu/~gurari/TeX4ht/)" />
|
|
<meta name="originator" content="TeX4ht (http://www.cse.ohio-state.edu/~gurari/TeX4ht/)" />
|
|
<!-- 2,html,xhtml -->
|
|
<meta name="src" content="haskell.tex" />
|
|
<meta name="date" content="2010-07-20 13:11:00" />
|
|
<link rel="stylesheet" type="text/css" href="haskell.css" />
|
|
</head><body
|
|
>
|
|
<!--l. 1--><div class="crosslinks"><p class="noindent">[<a
|
|
href="haskellch20.html" >next</a>] [<a
|
|
href="haskellch18.html" >prev</a>] [<a
|
|
href="haskellch18.html#tailhaskellch18.html" >prev-tail</a>] [<a
|
|
href="#tailhaskellch19.html">tail</a>] [<a
|
|
href="haskellpa2.html#haskellch19.html" >up</a>] </p></div>
|
|
<h2 class="chapterHead"><span class="titlemark">Chapter 19</span><br /><a
|
|
id="x27-22500019"></a><span
|
|
class="pcrr7t-">Data.Ix</span></h2>
|
|
<div class="quote">
|
|
|
|
|
|
|
|
<div class="verbatim" id="verbatim-391">
|
|
module Data.Ix (
|
|
 <br />    Ix(range, index, inRange, rangeSize)
|
|
 <br />  ) where
|
|
</div>
|
|
<p class="noindent"></div>
|
|
<h3 class="sectionHead"><span class="titlemark">19.1 </span> <a
|
|
id="x27-22600019.1"></a>The <span
|
|
class="pcrr7t-">Ix </span>class </h3>
|
|
<p class="noindent">
|
|
<dl> <dt class="haddockdesc">
|
|
<!--tex4ht:inline--><div class="tabular"> <table id="TBL-245" class="tabular"
|
|
cellspacing="0" cellpadding="0" rules="groups"
|
|
><colgroup id="TBL-245-1g"><col
|
|
id="TBL-245-1" /></colgroup><tr
|
|
style="vertical-align:baseline;" id="TBL-245-1-"><td style="white-space:nowrap; text-align:left;" id="TBL-245-1-1"
|
|
class="td11"><span
|
|
class="pcrb7t-">class</span><span
|
|
class="pcrb7t-"> Ord</span><span
|
|
class="pcrb7t-"> a</span><span
|
|
class="pcrb7t-"> =></span><span
|
|
class="pcrb7t-"> Ix</span><span
|
|
class="pcrb7t-"> a</span><span
|
|
class="pcrb7t-"> where </span></td></tr></table> </div> <dd class="haddockdesc">
|
|
The <span
|
|
class="pcrr7t-">Ix</span><a
|
|
id="dx27-226001"></a> class is used to map a contiguous subrange of values in a type onto integers. It is used primarily
|
|
for array indexing (see the array package).
|
|
<p class="noindent"> The first argument <span
|
|
class="pcrr7t-">(l,u) </span>of each of these operations is a pair specifying the lower and upper bounds
|
|
of a contiguous subrange of values.
|
|
<p class="noindent"> An implementation is entitled to assume the following laws about these operations:
|
|
<ul class="itemize1">
|
|
<li class="itemize"><span
|
|
class="pcrr7t-">inRange</span><span
|
|
class="pcrr7t-"> (l,u)</span><span
|
|
class="pcrr7t-"> i</span><span
|
|
class="pcrr7t-"> ==</span><span
|
|
class="pcrr7t-"> elem</span><span
|
|
class="pcrr7t-"> i</span><span
|
|
class="pcrr7t-"> (range</span><span
|
|
class="pcrr7t-"> (l,u))</span><span
|
|
class="pcrr7t-"> </span>
|
|
</li>
|
|
<li class="itemize"><span
|
|
class="pcrr7t-">range</span><span
|
|
class="pcrr7t-"> (l,u)</span><span
|
|
class="pcrr7t-"> !!</span><span
|
|
class="pcrr7t-"> index</span><span
|
|
class="pcrr7t-"> (l,u)</span><span
|
|
class="pcrr7t-"> i</span><span
|
|
class="pcrr7t-"> ==</span><span
|
|
class="pcrr7t-"> i</span>, when <span
|
|
class="pcrr7t-">inRange</span><span
|
|
class="pcrr7t-"> (l,u)</span><span
|
|
class="pcrr7t-"> i</span>
|
|
</li>
|
|
<li class="itemize"><span
|
|
class="pcrr7t-">map</span><span
|
|
class="pcrr7t-"> (index</span><span
|
|
class="pcrr7t-"> (l,u))</span><span
|
|
class="pcrr7t-"> (range</span><span
|
|
class="pcrr7t-"> (l,u)))</span><span
|
|
class="pcrr7t-"> ==</span><span
|
|
class="pcrr7t-"> [0..rangeSize</span><span
|
|
class="pcrr7t-"> (l,u)-1]</span><span
|
|
class="pcrr7t-"> </span>
|
|
</li>
|
|
<li class="itemize"><span
|
|
class="pcrr7t-">rangeSize</span><span
|
|
class="pcrr7t-"> (l,u)</span><span
|
|
class="pcrr7t-"> ==</span><span
|
|
class="pcrr7t-"> length</span><span
|
|
class="pcrr7t-"> (range</span><span
|
|
class="pcrr7t-"> (l,u))</span><span
|
|
class="pcrr7t-"> </span>
|
|
</li></ul>
|
|
<p class="noindent"> Minimal complete instance: <span
|
|
class="pcrr7t-">range</span><a
|
|
id="dx27-226002"></a>, <span
|
|
class="pcrr7t-">index</span><a
|
|
id="dx27-226003"></a> and <span
|
|
class="pcrr7t-">inRange</span><a
|
|
id="dx27-226004"></a>.
|
|
<p class="noindent"> <span
|
|
class="ptmb7t-">Methods</span>
|
|
<dl> <dt class="haddockdesc">
|
|
<!--tex4ht:inline--><div class="tabular"> <table id="TBL-246" class="tabular"
|
|
cellspacing="0" cellpadding="0" rules="groups"
|
|
><colgroup id="TBL-246-1g"><col
|
|
id="TBL-246-1" /></colgroup><tr
|
|
style="vertical-align:baseline;" id="TBL-246-1-"><td style="white-space:nowrap; text-align:left;" id="TBL-246-1-1"
|
|
class="td11"><span
|
|
class="pcrb7t-">range</span><span
|
|
class="pcrb7t-"> ::</span><span
|
|
class="pcrb7t-"> (a,</span><span
|
|
class="pcrb7t-"> a)</span><span
|
|
class="pcrb7t-"> -></span><span
|
|
class="pcrb7t-"> [a] </span></td></tr></table> </div> <dd class="haddockdesc">
|
|
The list of values in the subrange defined by a bounding pair.
|
|
</dl>
|
|
<p class="noindent">
|
|
<dl> <dt class="haddockdesc">
|
|
<!--tex4ht:inline--><div class="tabular"> <table id="TBL-247" class="tabular"
|
|
cellspacing="0" cellpadding="0" rules="groups"
|
|
><colgroup id="TBL-247-1g"><col
|
|
id="TBL-247-1" /></colgroup><tr
|
|
style="vertical-align:baseline;" id="TBL-247-1-"><td style="white-space:nowrap; text-align:left;" id="TBL-247-1-1"
|
|
class="td11"><span
|
|
class="pcrb7t-">index</span><span
|
|
class="pcrb7t-"> ::</span><span
|
|
class="pcrb7t-"> (a,</span><span
|
|
class="pcrb7t-"> a)</span><span
|
|
class="pcrb7t-"> -></span><span
|
|
class="pcrb7t-"> a</span><span
|
|
class="pcrb7t-"> -></span><span
|
|
class="pcrb7t-"> Int </span></td></tr></table> </div> <dd class="haddockdesc">
|
|
The position of a subscript in the subrange.
|
|
</dl>
|
|
|
|
|
|
|
|
<p class="noindent">
|
|
<dl> <dt class="haddockdesc">
|
|
<!--tex4ht:inline--><div class="tabular"> <table id="TBL-248" class="tabular"
|
|
cellspacing="0" cellpadding="0" rules="groups"
|
|
><colgroup id="TBL-248-1g"><col
|
|
id="TBL-248-1" /></colgroup><tr
|
|
style="vertical-align:baseline;" id="TBL-248-1-"><td style="white-space:nowrap; text-align:left;" id="TBL-248-1-1"
|
|
class="td11"><span
|
|
class="pcrb7t-">inRange</span><span
|
|
class="pcrb7t-"> ::</span><span
|
|
class="pcrb7t-"> (a,</span><span
|
|
class="pcrb7t-"> a)</span><span
|
|
class="pcrb7t-"> -></span><span
|
|
class="pcrb7t-"> a</span><span
|
|
class="pcrb7t-"> -></span><span
|
|
class="pcrb7t-"> Bool </span></td></tr></table> </div> <dd class="haddockdesc">
|
|
Returns <span
|
|
class="pcrr7t-">True</span><a
|
|
id="dx27-226005"></a> the given subscript lies in the range defined the bounding pair.
|
|
</dl>
|
|
<p class="noindent">
|
|
<dl> <dt class="haddockdesc">
|
|
<!--tex4ht:inline--><div class="tabular"> <table id="TBL-249" class="tabular"
|
|
cellspacing="0" cellpadding="0" rules="groups"
|
|
><colgroup id="TBL-249-1g"><col
|
|
id="TBL-249-1" /></colgroup><tr
|
|
style="vertical-align:baseline;" id="TBL-249-1-"><td style="white-space:nowrap; text-align:left;" id="TBL-249-1-1"
|
|
class="td11"><span
|
|
class="pcrb7t-">rangeSize</span><span
|
|
class="pcrb7t-"> ::</span><span
|
|
class="pcrb7t-"> (a,</span><span
|
|
class="pcrb7t-"> a)</span><span
|
|
class="pcrb7t-"> -></span><span
|
|
class="pcrb7t-"> Int </span></td></tr></table> </div> <dd class="haddockdesc">
|
|
The size of the subrange defined by a bounding pair.
|
|
</dl>
|
|
</dl>
|
|
<p class="noindent">
|
|
<dl> <dt class="haddockdesc">
|
|
<!--tex4ht:inline--><div class="tabular"> <table id="TBL-250" class="tabular"
|
|
cellspacing="0" cellpadding="0" rules="groups"
|
|
><colgroup id="TBL-250-1g"><col
|
|
id="TBL-250-1" /></colgroup><tr
|
|
style="vertical-align:baseline;" id="TBL-250-1-"><td style="white-space:nowrap; text-align:left;" id="TBL-250-1-1"
|
|
class="td11"><span
|
|
class="pcrb7t-">instance</span><span
|
|
class="pcrb7t-"> Ix</span><span
|
|
class="pcrb7t-"> Bool </span></td></tr><tr
|
|
style="vertical-align:baseline;" id="TBL-250-2-"><td style="white-space:nowrap; text-align:left;" id="TBL-250-2-1"
|
|
class="td11"><span
|
|
class="pcrb7t-">instance</span><span
|
|
class="pcrb7t-"> Ix</span><span
|
|
class="pcrb7t-"> Char</span></td>
|
|
</tr><tr
|
|
style="vertical-align:baseline;" id="TBL-250-3-"><td style="white-space:nowrap; text-align:left;" id="TBL-250-3-1"
|
|
class="td11"><span
|
|
class="pcrb7t-">instance</span><span
|
|
class="pcrb7t-"> Ix</span><span
|
|
class="pcrb7t-"> Int </span></td></tr><tr
|
|
style="vertical-align:baseline;" id="TBL-250-4-"><td style="white-space:nowrap; text-align:left;" id="TBL-250-4-1"
|
|
class="td11"><span
|
|
class="pcrb7t-">instance</span><span
|
|
class="pcrb7t-"> Ix</span><span
|
|
class="pcrb7t-"> Int8</span></td>
|
|
</tr><tr
|
|
style="vertical-align:baseline;" id="TBL-250-5-"><td style="white-space:nowrap; text-align:left;" id="TBL-250-5-1"
|
|
class="td11"><span
|
|
class="pcrb7t-">instance</span><span
|
|
class="pcrb7t-"> Ix</span><span
|
|
class="pcrb7t-"> Int16 </span></td></tr><tr
|
|
style="vertical-align:baseline;" id="TBL-250-6-"><td style="white-space:nowrap; text-align:left;" id="TBL-250-6-1"
|
|
class="td11"><span
|
|
class="pcrb7t-">instance</span><span
|
|
class="pcrb7t-"> Ix</span><span
|
|
class="pcrb7t-"> Int32</span></td>
|
|
</tr><tr
|
|
style="vertical-align:baseline;" id="TBL-250-7-"><td style="white-space:nowrap; text-align:left;" id="TBL-250-7-1"
|
|
class="td11"><span
|
|
class="pcrb7t-">instance</span><span
|
|
class="pcrb7t-"> Ix</span><span
|
|
class="pcrb7t-"> Int64 </span></td></tr><tr
|
|
style="vertical-align:baseline;" id="TBL-250-8-"><td style="white-space:nowrap; text-align:left;" id="TBL-250-8-1"
|
|
class="td11"><span
|
|
class="pcrb7t-">instance</span><span
|
|
class="pcrb7t-"> Ix</span><span
|
|
class="pcrb7t-"> Integer</span></td>
|
|
</tr><tr
|
|
style="vertical-align:baseline;" id="TBL-250-9-"><td style="white-space:nowrap; text-align:left;" id="TBL-250-9-1"
|
|
class="td11"><span
|
|
class="pcrb7t-">instance</span><span
|
|
class="pcrb7t-"> Ix</span><span
|
|
class="pcrb7t-"> Ordering </span></td>
|
|
</tr><tr
|
|
style="vertical-align:baseline;" id="TBL-250-10-"><td style="white-space:nowrap; text-align:left;" id="TBL-250-10-1"
|
|
class="td11"><span
|
|
class="pcrb7t-">instance</span><span
|
|
class="pcrb7t-"> Ix</span><span
|
|
class="pcrb7t-"> Word </span></td></tr><tr
|
|
style="vertical-align:baseline;" id="TBL-250-11-"><td style="white-space:nowrap; text-align:left;" id="TBL-250-11-1"
|
|
class="td11"><span
|
|
class="pcrb7t-">instance</span><span
|
|
class="pcrb7t-"> Ix</span><span
|
|
class="pcrb7t-"> Word8</span></td>
|
|
</tr><tr
|
|
style="vertical-align:baseline;" id="TBL-250-12-"><td style="white-space:nowrap; text-align:left;" id="TBL-250-12-1"
|
|
class="td11"><span
|
|
class="pcrb7t-">instance</span><span
|
|
class="pcrb7t-"> Ix</span><span
|
|
class="pcrb7t-"> Word16 </span></td>
|
|
</tr><tr
|
|
style="vertical-align:baseline;" id="TBL-250-13-"><td style="white-space:nowrap; text-align:left;" id="TBL-250-13-1"
|
|
class="td11"><span
|
|
class="pcrb7t-">instance</span><span
|
|
class="pcrb7t-"> Ix</span><span
|
|
class="pcrb7t-"> Word32 </span></td>
|
|
</tr><tr
|
|
style="vertical-align:baseline;" id="TBL-250-14-"><td style="white-space:nowrap; text-align:left;" id="TBL-250-14-1"
|
|
class="td11"><span
|
|
class="pcrb7t-">instance</span><span
|
|
class="pcrb7t-"> Ix</span><span
|
|
class="pcrb7t-"> Word64 </span></td>
|
|
</tr><tr
|
|
style="vertical-align:baseline;" id="TBL-250-15-"><td style="white-space:nowrap; text-align:left;" id="TBL-250-15-1"
|
|
class="td11"><span
|
|
class="pcrb7t-">instance</span><span
|
|
class="pcrb7t-"> Ix</span><span
|
|
class="pcrb7t-"> () </span></td>
|
|
</tr><tr
|
|
style="vertical-align:baseline;" id="TBL-250-16-"><td style="white-space:nowrap; text-align:left;" id="TBL-250-16-1"
|
|
class="td11"><span
|
|
class="pcrb7t-">instance</span><span
|
|
class="pcrb7t-"> Ix</span><span
|
|
class="pcrb7t-"> GeneralCategory </span></td>
|
|
</tr><tr
|
|
style="vertical-align:baseline;" id="TBL-250-17-"><td style="white-space:nowrap; text-align:left;" id="TBL-250-17-1"
|
|
class="td11"><span
|
|
class="pcrb7t-">instance</span><span
|
|
class="pcrb7t-"> Ix</span><span
|
|
class="pcrb7t-"> SeekMode </span></td>
|
|
</tr><tr
|
|
style="vertical-align:baseline;" id="TBL-250-18-"><td style="white-space:nowrap; text-align:left;" id="TBL-250-18-1"
|
|
class="td11"><span
|
|
class="pcrb7t-">instance</span><span
|
|
class="pcrb7t-"> Ix</span><span
|
|
class="pcrb7t-"> IOMode </span></td>
|
|
</tr><tr
|
|
style="vertical-align:baseline;" id="TBL-250-19-"><td style="white-space:nowrap; text-align:left;" id="TBL-250-19-1"
|
|
class="td11"><span
|
|
class="pcrb7t-">instance</span><span
|
|
class="pcrb7t-"> (Ix</span><span
|
|
class="pcrb7t-"> a,</span><span
|
|
class="pcrb7t-"> Ix</span><span
|
|
class="pcrb7t-"> b)</span><span
|
|
class="pcrb7t-"> =></span><span
|
|
class="pcrb7t-"> Ix</span><span
|
|
class="pcrb7t-"> (a,</span><span
|
|
class="pcrb7t-"> b) </span></td>
|
|
</tr><tr
|
|
style="vertical-align:baseline;" id="TBL-250-20-"><td style="white-space:nowrap; text-align:left;" id="TBL-250-20-1"
|
|
class="td11"><span
|
|
class="pcrb7t-">instance</span><span
|
|
class="pcrb7t-"> (Ix</span><span
|
|
class="pcrb7t-"> a1,</span><span
|
|
class="pcrb7t-"> Ix</span><span
|
|
class="pcrb7t-"> a2,</span><span
|
|
class="pcrb7t-"> Ix</span><span
|
|
class="pcrb7t-"> a3)</span><span
|
|
class="pcrb7t-"> =></span><span
|
|
class="pcrb7t-"> Ix</span><span
|
|
class="pcrb7t-"> (a1,</span><span
|
|
class="pcrb7t-"> a2,</span><span
|
|
class="pcrb7t-"> a3) </span></td>
|
|
</tr><tr
|
|
style="vertical-align:baseline;" id="TBL-250-21-"><td style="white-space:nowrap; text-align:left;" id="TBL-250-21-1"
|
|
class="td11"><span
|
|
class="pcrb7t-">instance</span><span
|
|
class="pcrb7t-"> (Ix</span><span
|
|
class="pcrb7t-"> a1,</span><span
|
|
class="pcrb7t-"> Ix</span><span
|
|
class="pcrb7t-"> a2,</span><span
|
|
class="pcrb7t-"> Ix</span><span
|
|
class="pcrb7t-"> a3,</span><span
|
|
class="pcrb7t-"> Ix</span><span
|
|
class="pcrb7t-"> a4)</span><span
|
|
class="pcrb7t-"> =></span><span
|
|
class="pcrb7t-"> Ix</span><span
|
|
class="pcrb7t-"> (a1,</span><span
|
|
class="pcrb7t-"> a2,</span><span
|
|
class="pcrb7t-"> a3,</span><span
|
|
class="pcrb7t-"> a4) </span></td>
|
|
</tr><tr
|
|
style="vertical-align:baseline;" id="TBL-250-22-"><td style="white-space:nowrap; text-align:left;" id="TBL-250-22-1"
|
|
class="td11"><span
|
|
class="pcrb7t-">instance</span><span
|
|
class="pcrb7t-"> (Ix</span><span
|
|
class="pcrb7t-"> a1,</span><span
|
|
class="pcrb7t-"> Ix</span><span
|
|
class="pcrb7t-"> a2,</span><span
|
|
class="pcrb7t-"> Ix</span><span
|
|
class="pcrb7t-"> a3,</span><span
|
|
class="pcrb7t-"> Ix</span><span
|
|
class="pcrb7t-"> a4,</span><span
|
|
class="pcrb7t-"> Ix</span><span
|
|
class="pcrb7t-"> a5)</span><span
|
|
class="pcrb7t-"> =></span><span
|
|
class="pcrb7t-"> Ix</span><span
|
|
class="pcrb7t-"> (a1,</span><span
|
|
class="pcrb7t-"> a2,</span><span
|
|
class="pcrb7t-"> a3,</span><span
|
|
class="pcrb7t-"> a4,</span><span
|
|
class="pcrb7t-"> a5) </span></td>
|
|
</tr></table> </div> <dd class="haddockdesc">
|
|
</dl>
|
|
<p class="noindent">
|
|
<h3 class="sectionHead"><span class="titlemark">19.2 </span> <a
|
|
id="x27-22700019.2"></a>Deriving Instances of <span
|
|
class="pcrr7t-">Ix</span></h3>
|
|
<p class="noindent"> It is possible to derive an instance of <span
|
|
class="pcrr7t-">Ix </span>automatically, using a <span
|
|
class="pcrr7t-">deriving </span>clause on a <span
|
|
class="pcrr7t-">data </span>declaration. Such
|
|
derived instance declarations for the class <span
|
|
class="pcrr7t-">Ix </span>are only possible for enumerations (i.e. datatypes having only nullary
|
|
constructors) and single-constructor datatypes, whose constituent types are instances of <span
|
|
class="pcrr7t-">Ix</span>. A Haskell
|
|
implementation must provide <span
|
|
class="pcrr7t-">Ix </span>instances for tuples up to at least size 15.
|
|
<p class="noindent"> For an <span
|
|
class="ptmri7t-">enumeration</span>, the nullary constructors are assumed to be numbered left-to-right with the indices
|
|
being 0 to n-1 inclusive. This is the same numbering defined by the <span
|
|
class="pcrr7t-">Enum </span>class. For example, given the
|
|
datatype:
|
|
<p class="noindent">
|
|
<div class="quote">
|
|
|
|
|
|
|
|
<div class="verbatim" id="verbatim-392">
|
|
 data Colour = Red | Orange | Yellow | Green | Blue | Indigo | Violet
|
|
</div>
|
|
<p class="noindent"></div>
|
|
<p class="noindent"> we would have:
|
|
<p class="noindent">
|
|
<div class="quote">
|
|
|
|
|
|
|
|
<div class="verbatim" id="verbatim-393">
|
|
 range   (Yellow,Blue)        ==  [Yellow,Green,Blue]
|
|
 <br /> index   (Yellow,Blue) Green  ==  1
|
|
 <br /> inRange (Yellow,Blue) Red    ==  False
|
|
</div>
|
|
<p class="noindent"></div>
|
|
<p class="noindent"> For <span
|
|
class="ptmri7t-">single-constructor datatypes</span>, the derived instance declarations are as shown for tuples:
|
|
<p class="noindent">
|
|
<div class="quote">
|
|
|
|
|
|
|
|
<div class="verbatim" id="verbatim-394">
|
|
 instance  (Ix a, Ix b)  => Ix (a,b) where
|
|
 <br />         range ((l,l'),(u,u'))
|
|
 <br />                 = [(i,i') | i <- range (l,u), i' <- range (l',u')]
|
|
 <br />         index ((l,l'),(u,u')) (i,i')
|
|
 <br />                 =  index (l,u) i ⋆ rangeSize (l',u') + index (l',u') i'
|
|
 <br />         inRange ((l,l'),(u,u')) (i,i')
|
|
 <br />                 = inRange (l,u) i && inRange (l',u') i'
|
|
 <br />
|
|
 <br /> -- Instances for other tuples are obtained from this scheme:
|
|
 <br /> --
|
|
 <br /> --  instance  (Ix a1, Ix a2, ... , Ix ak) => Ix (a1,a2,...,ak)  where
|
|
 <br /> --      range ((l1,l2,...,lk),(u1,u2,...,uk)) =
|
|
 <br /> --          [(i1,i2,...,ik) | i1 <- range (l1,u1),
|
|
 <br /> --                            i2 <- range (l2,u2),
|
|
 <br /> --                            ...
|
|
 <br /> --                            ik <- range (lk,uk)]
|
|
 <br /> --
|
|
 <br /> --      index ((l1,l2,...,lk),(u1,u2,...,uk)) (i1,i2,...,ik) =
|
|
 <br /> --        index (lk,uk) ik + rangeSize (lk,uk) ⋆ (
|
|
 <br /> --         index (lk-1,uk-1) ik-1 + rangeSize (lk-1,uk-1) ⋆ (
|
|
 <br /> --          ...
|
|
 <br /> --           index (l1,u1)))
|
|
 <br /> --
|
|
 <br /> --      inRange ((l1,l2,...lk),(u1,u2,...,uk)) (i1,i2,...,ik) =
|
|
 <br /> --          inRange (l1,u1) i1 && inRange (l2,u2) i2 &&
|
|
 <br /> --              ... && inRange (lk,uk) ik
|
|
</div>
|
|
<p class="noindent"></div>
|
|
<!--l. 1--><div class="crosslinks"><p class="noindent">[<a
|
|
href="haskellch20.html" >next</a>] [<a
|
|
href="haskellch18.html" >prev</a>] [<a
|
|
href="haskellch18.html#tailhaskellch18.html" >prev-tail</a>] [<a
|
|
href="haskellch19.html" >front</a>] [<a
|
|
href="haskellpa2.html#haskellch19.html" >up</a>] </p></div>
|
|
<p class="noindent"> <a
|
|
id="tailhaskellch19.html"></a>
|
|
</body></html>
|